home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / kcl.lha / doc / report < prev    next >
Lisp/Scheme  |  1986-05-21  |  206KB  |  4,848 lines

  1.  
  2. \(progn
  3.  
  4.   (defmacro set-page (name) `(setq ,name *page-number*))
  5.   (defun date ()
  6.     (multiple-value-bind (sec min hour date month year) (get-decoded-time)
  7.       (do-string
  8.     (format nil
  9.                 "~[January~;February~;March~;April~;May~;June~;July~;~
  10.            August~;September~;October~;November~;December~] ~
  11.                  ~d, ~d"
  12.         (1- month)
  13.                 date
  14.                 year))))
  15.   (defun fr () (setq *current-font* *font-roman*))
  16.   (defun fi () (setq *current-font* *font-italic*))
  17.   (defun fs () (setq *current-font* *font-symbol*))
  18.   (defun fp () (setq *current-font* *font-prop*))
  19.   (defun fg () (setq *current-font* *font-big*))
  20.   (defun sm () (setq *old-left-margin* *left-margin*)
  21.            (setq *left-margin* (+ (mark-column) *left-margin*)))
  22.   (defun rm () (do-line-so-far) (setq *left-margin* *old-left-margin*))
  23.   (defun ra () (right-adjust))
  24.   (defun ce () (centering))
  25.   (defun br () (break-line))
  26.   (defun lm (n) (setq *left-margin* n))
  27.   (defun bd () (setq *left-margin* 100))
  28.   (defun endd () (do-line-so-far) (setq *left-margin* 0))
  29.   (defun reserve (n)
  30.                  (do-line-so-far)
  31.                  (when (< *bottom-hight*
  32.               (* (1+ n)
  33.                  (+ (font-ils *font-prop*)
  34.                 (font-hight *font-prop*))))
  35.                (do-page)))
  36. )
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. \(fg) 
  52. \(ce)Kyoto Common Lisp Report
  53. \(fr)
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. \(ce)Taiichi Yuasa and Masami Hagiya
  63.  
  64. \(ce)Research Institute for Mathematical Sciences, Kyoto University
  65.  
  66.  
  67. \(fg) 
  68.  
  69. \(ce)Preface
  70. \(set-page pp-preface)
  71. \(fr)
  72. Kyoto Common Lisp (KCL for short) is a full
  73. implementation of the Common Lisp language described in
  74. the \(fi)Common Lisp Reference Manual\(fr):
  75.  
  76.  
  77. \(ce)\(fi)Common Lisp: The Language\(fr).
  78. \(ce)by Guy L. Steele et al.
  79. \(ce)Digital Press, 1984
  80.  
  81. All Common Lisp functions, macros, and special forms
  82. are defined in KCL, though a few of them have
  83. slightly different meanings from those described in the \(fi)Common Lisp
  84. Reference Manual\(fr).  All such differences are described in this
  85. report:  If a Common Lisp function (or macro or special
  86. form) does not work as
  87. described in the \(fi)Common Lisp Reference Manual\(fr) and if this report
  88. does not describe the difference explicitly, then there must be a bug in
  89. KCL.  All Common Lisp variables and constants are
  90. defined in KCL exactly as described in the \(fi)Common Lisp Reference Manual\(fr).
  91.  
  92.      Currently, there are four major versions of KCL:
  93.  
  94.     1. \(sm)KCL/AOS, under the AOS/VS operating system for Data General's ECLIPSE MV series machines.\(rm)
  95.  
  96.     2. \(sm)KCL/VAX, under the Unix 4.2 bsd operating system for Digital Equipment Corporation's VAX 11 series machines.\(rm)
  97.  
  98.     3. \(sm)KCL/SUN, under the Unix 4.2 bsd operating system for Sun Microsystems' Sun Workstation.\(rm)
  99.  
  100.     4. \(sm)KCL/UST, under the Unix V (Uniplus' version) operating system for Sumitomo Electric Industries and Digital Computer Laboratory's Ustation E15.\(rm)
  101.  
  102. KCL/AOS is the original version of KCL, which was developed
  103. at Research Institute for Mathematical Sciences (RIMS), Kyoto University,
  104. with the cooperation of Nippon Data General Corporation.  The other three
  105. versions, which are collectively called \(fi)KCL on Unix\(fr),
  106. are transplanted versions of KCL/AOS.
  107.  
  108.      This report is intended to complement the \(fi)Common Lisp Reference
  109. Manual\(fr).  This report describes deviations of KCL from Common Lisp,
  110. those features specific to KCL,
  111. and the implementation-dependent functions of Common Lisp.
  112. \(fg)
  113.  
  114. \(ce)Acknowledgements
  115. \(set-page pp-acknowledgements)
  116. \(fr)
  117. The project of KCL was supported by many people affiliated with many
  118. institutions.  We are very grateful especially to the following people for
  119. their contributions to the project of KCL.
  120.  
  121.      First of all, we are grateful to the contributors of the design of Common Lisp.
  122.  
  123.      Prof. Reiji Nakajima at RIMS, Kyoto University, provided us with
  124. considerable encouragement and moral support.
  125.      Nippon Data General Corporation (NDG) helped us implement KCL/AOS.  Mr. Teruo Yabe and Mr. Toshiyasu Harada joined us
  126. during the first stage of the KCL project
  127. and did a lot of coding.  Mr. Takashi Suzuki and Mr. Kibo Kurokawa arranged
  128. the joint project.  NDG is now supporting the distribution of KCL/AOS.
  129.      Data General Corporation in the United States sent us
  130. materials necessary to
  131. implement a Common Lisp system, such as the preliminary drafts of the
  132. Common Lisp reference manual and benchmark tests for Common Lisp.  The benchmark tests are indebted to Dr. Richard Gabriel at Stanford
  133. University.
  134.      Dr. Daniel Weinreb at Symbolics solved most of our questions about the
  135. language specification.  He also sent us the definition
  136. of \(fp)rationalize\(ri 'rationalize)\(fr) written by Dr. Skef Wholey at CMU.  We use this definition in KCL without any change.
  137.      Dr. Carl Hoffman at Symbolics checked the top-level of KCL and
  138. gave us advices to improve KCL.  He also found some bugs in KCL and
  139. fixed them for us.
  140.      Mr. Naruhiko Kawamura at RIMS developed a Prolog system
  141. using the earliest version of KCL/AOS.  That was one of the first big projects with KCL and he found many bugs.
  142.      Mr. Takashi Sakuragawa at RIMS hacked with KCL/AOS and gave us many
  143. advises concerning with those features specific to KCL.
  144.      Mr. Tatsuya Hagino at Edinburgh University developed Micro EMACS on
  145. which FeCl2, the full-screen editor embedded in KCL/AOS, is based.
  146.      Mr. Kunihiko Nakamura at Kagawa University converted the assembly
  147. language
  148. version of Micro EMACS into the C language, which happened to become the
  149. prototype of FeCl2.
  150.      Prof. Akinori Yonezawa at Tokyo Institute of Technology encouraged us
  151. to port KCL/AOS onto VAX 11.
  152.      Mr. Etsuya Shibayama at Tokyo Institute of Technology helped us
  153. while we were working with the VAX 11 at the Institute.
  154.      Hagiwara Laboratory at Kyoto University offered (and is offering) their
  155. VAX 11 for finishing transplantation and maintaining KCL/VAX.  We got also technical advises from people at Hagiwara Laboratory.
  156.      Prof. Shuji Doshita at Kyoto University offered the SUN Workstation at
  157. his Laboratory and gave us
  158. a lot of advises for transplantation to SUN Workstation.
  159.      Mr. Takashi Hattori at RIMS gave us useful information about Motorola
  160. 68000, the CPU chip of SUN Workstation.
  161.  
  162.      NDG helped us build up the KROFF (\(fi)K\(fr)yoto \(fi)ROFF\(fr))
  163. system, with which this report was produced.  They offered the character
  164. font sets from
  165. which the font sets used in KROFF were constructed.  We also received some
  166. technical
  167. advises from NDG about the output devise of KROFF, i.e., NDG's 5880 series
  168. laser beam
  169. printers.  Incidentally, all the programs that constitute the KROFF system,
  170. including tools
  171. to maintain KROFF font sets, are written in the Common Lisp language
  172. and are running
  173. under KCL.
  174.  
  175. \(fg) 
  176.  
  177. \(ce)Table of Contents
  178. \(set-page pp-contents)
  179. \(fr)
  180.  
  181. Insert the first page of "Table of Contents" here.
  182.  
  183. \(fg) 
  184.  
  185. \(ce)Table of Contents (Cont.)
  186.  
  187. \(fr)
  188.  
  189. Insert the second page of "Table of Contents" here.
  190.  
  191. \(fg) 
  192.  
  193. \(ce)Chapter 1. How to Start and End a KCL Session
  194. \(set-page pp-1)
  195. \(fr)
  196. KCL on Unix is invoked by the Shell command \(fp)kcl\(fr).
  197. \(reserve 2)\(fp)
  198.         % kcl
  199.     KCL (Kyoto Common Lisp)  \(do-string (lisp-implementation-version))
  200. \(fr)
  201.  
  202. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  203.  
  204. KCL/AOS is invoked by the CLI command \(fp)KCL\(fr).
  205. \(reserve 2)\(fp)
  206.         ) KCL
  207.     KCL (Kyoto Common Lisp)  \(do-string (lisp-implementation-version))\(fr)
  208.  
  209. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  210.  
  211.  
  212. When invoked, KCL will print the banner
  213. and initializes the system.  The date in the KCL banner
  214. identifies the revision of KCL.  "\(fp)\(do-string (lisp-implementation-version))\(fr)" is the value of the
  215. function \(fp)lisp-implementation-version\(ri 'lisp-implementation-version)\(fr).
  216.  
  217.      If there exists a file named \(fp)init.lsp\(fr) in the current working
  218. directory,
  219. KCL successively evaluates the forms in the file,
  220. immediately after the system initialization.  The user may set up his or her own KCL environment
  221. (e.g., the memory configuration) by \(fp)init.lsp\(fr).
  222.  
  223.      After the initialization, KCL enters the \(fi)top-level loop\(fr) and
  224. prints the prompt '\(fp)>\(fr)'.
  225. \(fp)
  226.     >
  227. \(fr)
  228. The prompt indicates that KCL is now ready to receive a form from the terminal
  229. and to evaluate it.
  230.  
  231.      Usually, the current package (i.e., the value
  232. of \(fp)*package*\(ri '*package*)\(fr)) is the \(fp)user\(fr) package, and the prompt appears
  233. as above.  If, however, the current package is other than the \(fp)user\(fr)
  234. package, then the prompt will be prefixed by the package name.
  235.  
  236.     \(fi)package-name\(fp)>\(fr)
  237.  
  238.      To exit from KCL,
  239. call the function \(fp)bye\(ri 'bye)\(fr) (or \(fp)by\(ri 'by)\(fr)).
  240. \(reserve 3)\(fp)
  241.     >(bye)
  242.     Bye.
  243.     %
  244. \(fr)
  245.  
  246. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  247.  
  248. In this report, we sometimes assume that KCL is invoked
  249. from the Unix Shell.  In particular, we use the standard prompt
  250. of the Unix Shell '\(fp)%\(fr)' in most examples.
  251.  
  252. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  253.  
  254.  
  255. Alternatively, you may type ^D (control-D),
  256. i.e., press the key D while pressing down the
  257. CNTL key.
  258. \(reserve 2)\(fp)
  259.     >^DBye.
  260.     %
  261. \(fr)
  262.      The top-level loop of KCL is almost the same as that
  263. defined in Section 20.2 of the \(fi)Common Lisp Reference
  264. Manual\(fr).  Since the input from the terminal is in line mode,
  265. each top-level form should be followed by a newline.  If more
  266. than one values are returned by the evaluation of the top-level form,
  267. the values will be printed successively.  If no value is returned, then
  268. nothing will be printed.
  269. \(reserve 7)\(fp)
  270.     >(values 1 2)
  271.     1
  272.     2
  273.  
  274.     >(values)
  275.     
  276.     >
  277. \(fr)
  278.      When an error is signalled, control will enter the break loop.
  279. \(reserve 12)\(fp)
  280.     >(defun foo (x) (bar x))
  281.     foo
  282.  
  283.     >(defun bar (y) (bee y y))
  284.     bar
  285.  
  286.     >(foo 'lish)
  287.     Error: The function BEE is undefined.
  288.     Error signalled by BAR.
  289.  
  290.     Broken at BAR.
  291.     >>
  292. \(fr)
  293. '\(fp)>>\(fr)' in the last line is the prompt of
  294. the break loop.  Like in the top-level loop,
  295. the prompt will be prefixed by the current package name,
  296. if the current package is other than the \(fp)user\(fr) package.
  297.  
  298.      To go back to the top-level loop, type \(fp):q\(ri ':q)\(fr).
  299. \(reserve 4)\(fp)
  300.     >>:q
  301.  
  302.     Top level.
  303.     >\(fr)
  304.  
  305. See Section 5.4 for the details of the break loop.
  306.  
  307.      In KCL on Unix, the terminal
  308. interrupt (usually caused by typing ^C (control-C) or by
  309. typing DELETE) is a kind of error.  It breaks the running program and calls
  310. the break level loop.
  311.  
  312.      Example:
  313. \(fp)
  314.     >(defun foo () (do () (nil)))
  315.     foo
  316.  
  317.     >(foo)
  318.     ^C
  319.     Correctable error: Console interrupt.
  320.     Signalled by DO.
  321.  
  322.     Broken at FOO.
  323.     >>
  324. \(fr)
  325.  
  326. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  327.  
  328. In KCL/AOS, the console interrupt caused by typing ^C (control-C)
  329. followed by ^A (control-A)
  330. is a kind of error.  Typing ^C and ^A breaks the running program
  331. and calls the break loop.  On the other hand, the console interrupt
  332. caused by ^C and ^B (control-B) will immediately terminate KCL.
  333. \(reserve 12)
  334.      Example:
  335. \(fp)
  336.     >(defun foo () (do () (nil)))
  337.     foo
  338.  
  339.     >(foo)
  340.     ^C^A
  341.     Correctable error: Console interrupt.
  342.     Signalled by DO.
  343.  
  344.     Broken at FOO.
  345.     >>(foo)
  346.     ^C^B
  347.     *ABORT*
  348.     CONSOLE INTERRUPT
  349.     ERROR: FROM PROGRAM
  350.     LEVEL 1
  351.     x,kcl
  352.     )\(fr)
  353.  
  354. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  355.  
  356. \(fg) 
  357.  
  358. \(ce)Chapter 2. Data Types
  359. \(set-page pp-2)
  360. \(fr)
  361. KCL supports all Common Lisp data types exactly as defined in the
  362. \(fi)Common Lisp Reference Manual\(fr).  This chapter simply complements
  363. Chapter 2 of the \(fi)Common Lisp Reference Manual\(fr), by
  364. describing implementation dependent features of Common Lisp data
  365. types.  Each section in this chapter corresponds to the section in Chapter 2
  366. of the \(fi)Common Lisp Reference Manual\(fr), with the same section title.
  367.  
  368. \(reserve 5)\(fg)
  369. 2.1. Numbers\(set-page pp-2-1)
  370.  
  371. 2.1.1. Integers\(set-page pp-2-1-1)
  372. \(fr)
  373.      Fixnums in KCL are those integers
  374. in the range \(fp)-\(fr)(\(fp)2\(fr) to the power of \(fp)31\(fr)) to
  375. (\(fp)2\(fr) to the power of \(fp)31\(fr))\(fp)-1\(fr),
  376. inclusive.  Other integers are bignums.  Thus
  377. \(fp)25\(fr) factorial (\(fp)25!\(fr))
  378. \(fp)
  379.     15511210043330985984000000
  380. \(fr)
  381. is certainly a bignum in KCL.
  382.  
  383.      Common Lisp constants related to integers have the following values
  384. in KCL.
  385. \(fp)
  386.     most-positive-fixnum = 2147483647 = \(fr)(\(fp)2\(fr) to the power of \(fp)31\(fr))\(fp)-1\(ri 'most-positive-fixnum)
  387.     most-negative-fixnum = -2147483648 = -\(fr)(\(fp)2\(fr) to the power of \(fp)31\(fr))\(ri 'most-negative-fixnum)
  388. \(fp)
  389.     boole-1 = 3\(ri 'boole-1)
  390.     boole-2 = 5\(ri 'boole-2)
  391.     boole-and = 1\(ri 'boole-and)
  392.     boole-andc1 = 4\(ri 'boole-andc1)
  393.     boole-andc2 = 2\(ri 'boole-andc2)
  394.     boole-c1 = 12\(ri 'boole-c1)
  395.     boole-c2 = 10\(ri 'boole-c2)
  396.     boole-clr = 0\(ri 'boole-clr)
  397.     boole-eqv = 9\(ri 'boole-eqv)
  398.     boole-ior = 7\(ri 'boole-ior)
  399.     boole-nand = 14\(ri 'boole-nand)
  400.     boole-nor = 8\(ri 'boole-nor)
  401.     boole-orc1 = 13\(ri 'boole-orc1)
  402.     boole-orc2 = 11\(ri 'boole-orc2)
  403.     boole-set = 15\(ri 'boole-set)
  404.     boole-xor = 6\(ri 'boole-xor)
  405. \(fr)
  406. See Chapter 12 of the \(fi)Common Lisp Reference Manual\(fr) for their
  407. meanings.
  408.  
  409. \(reserve 5)\(fg)
  410. 2.1.2. Ratios\(set-page pp-2-1-2)
  411. \(fr)
  412. There are no implementation-dependent features for ratios.
  413.  
  414. \(reserve 5)\(fg)
  415. 2.1.3. Floating-Point Numbers\(set-page pp-2-1-3)
  416. \(fr)
  417. KCL provides two distinct internal floating-point formats.  One format
  418. is \(fi)short\(fr); the other
  419. is \(fi)single\(fr) and serves also as \(fi)double\(fr) and
  420. \(fi)long\(fr).  The data types
  421. \(fp)single-float\(fr), \(fp)double-float\(fr), and \(fp)long-float\(fr)
  422. are considered to be identical, but \(fp)short-float\(fr) is
  423. distinct.  An expression such
  424. as \(fp)(eql 1.0s0 1.0d0)\(fr) is false, but
  425. \(fp)(eql 1.0f0 1.0d0)\(fr) is true.  Similarly,
  426. \(fp)(typep 1.0L0 'short-float)\(fr) is false, but
  427. \(fp)(typep 1.0L0 'single-float)\(fr) is true.  For output purposes all
  428. floating-point numbers are assumed to be of \(fi)short\(fr)
  429. or \(fi)single\(fr) format.
  430.  
  431.      The floating-point precisions are:
  432. \(reserve 6)
  433.     \(fi)Format    \(fr)KCL/AOS        KCL/VAX    KCL/SUN        KCL/UST
  434.     \(fs)----------------------------------------------------------------\(fr)
  435.     Short        24 bits        23 bits        24 bits        24 bits
  436.     Single    56 bits        55 bits        53 bits        53 bits
  437.     Double    56 bits        55 bits        53 bits        53 bits
  438.     Long        56 bits        55 bits        53 bits        53 bits
  439.  
  440. The floating-point exponent sizes are:
  441. \(reserve 6)
  442.     \(fi)Format    \(fr)KCL/AOS        KCL/VAX    KCL/SUN        KCL/UST
  443.     \(fs)----------------------------------------------------------------\(fr)
  444.     Short        7 bits        8 bits        8 bits        8 bits
  445.     Single    7 bits        8 bits        11 bits        11 bits
  446.     Double    7 bits        8 bits        11 bits        11 bits
  447.     Long        7 bits        8 bits        11 bits        11 bits
  448.  
  449. There is no "minus zero."  \(fp)(eql 0.0 -0.0)\(fr) is true.
  450.  
  451.      Common Lisp constants related to floating-point numbers
  452. have the following values in KCL.
  453. \(reserve 5)\(fp)
  454.     most-positive-short-float\(ri 'most-positive-short-float)
  455.       = - most-negative-short-float\(ri 'most-negative-short-float)
  456.       = 7.237005s75 \(fr)(KCL/AOS)\(fp)
  457.         1.701412s38 \(fr)(KCL/VAX)\(fp)
  458.         3.402823s38 \(fr)(KCL/SUN and KCL/UST)\(fp)
  459. \(reserve 5)
  460.     least-positive-short-float\(ri 'least-positive-short-float)
  461.       = - least-negative-short-float\(ri 'least-negative-short-float)
  462.       = 5.397605s-79 \(fr)(KCL/AOS)\(fp)
  463.         2.938736s-39 \(fr)(KCL/VAX)\(fp)
  464.         1.401298s-45 \(fr)(KCL/SUN and KCL/UST)\(fp)
  465. \(reserve 9)
  466.     most-positive-long-float\(ri 'most-positive-long-float)
  467.       = most-positive-double-float\(ri 'most-positive-double-float)
  468.       = most-positive-single-float\(ri 'most-positive-single-float)
  469.       = - most-negative-long-float\(ri 'most-negative-long-float)
  470.       = - most-negative-double-float\(ri 'most-negative-double-float)
  471.       = - most-negative-single-float\(ri 'most-negative-single-float)
  472.       = 7.237005577332264f75 \(fr)(KCL/AOS)\(fp)
  473.         1.701411834604692f38 \(fr)(KCL/VAX)\(fp)
  474.         1.797693134862315f308 \(fr)(KCL/SUN and KCL/UST)\(fp)
  475. \(reserve 9)
  476.     least-positive-long-float\(ri 'least-positive-long-float)
  477.       = least-positive-double-float\(ri 'least-positive-double-float)
  478.       = least-positive-single-float\(ri 'least-positive-single-float)
  479.       = - least-negative-long-float\(ri 'least-negative-long-float)
  480.       = - least-negative-double-float\(ri 'least-negative-double-float)
  481.       = - least-negative-single-float\(ri 'least-negative-single-float)
  482.       = 5.397605346934027f-79 \(fr)(KCL/AOS)\(fp)
  483.         2.938735877055719f-39 \(fr)(KCL/VAX)\(fp)
  484.         4.940656458412469f-324 \(fr)(KCL/SUN and KCL/UST)\(fp)
  485. \(reserve 4)
  486.     short-float-epsilon\(ri 'short-float-epsilon)
  487.       = 4.468372s-7 \(fr)(KCL/AOS)\(fp)
  488.         6.938894s-18 \(fr)(KCL/VAX)\(fp)
  489.         2.980232s-8 \(fr)(KCL/SUN and KCL/UST)\(fp)
  490. \(reserve 4)
  491.     short-float-negative-epsilon\(ri 'short-float-negative-epsilon)
  492.       = 2.980232s-8 \(fr)(KCL/AOS)\(fp)
  493.         6.938894s-18 \(fr)(KCL/VAX)\(fp)
  494.         2.980232s-8 \(fr)(KCL/SUN and KCL/UST)\(fp)
  495. \(reserve 6)
  496.     long-float-epsilon\(ri 'long-float-epsilon)
  497.       = double-float-epsilon\(ri 'double-float-epsilon)
  498.       = single-float-epsilon\(ri 'single-float-epsilon)
  499.       = 1.110223024625157f-16 \(fr)(KCL/AOS)\(fp)
  500.         6.938893903907228f-18 \(fr)(KCL/VAX)\(fp)
  501.         5.5511151231257827f-17 \(fr)(KCL/SUN and KCL/UST)\(fp)
  502. \(reserve 6)
  503.     long-float-negative-epsilon\(ri 'long-float-negative-epsilon)
  504.       = double-float-negative-epsilon\(ri 'double-float-negative-epsilon)
  505.       = single-float-negative-epsilon\(ri 'single-float-negative-epsilon)
  506.       = 6.938893903907228f-18 \(fr)(KCL/AOS)\(fp)
  507.         6.938893903907228f-18 \(fr)(KCL/VAX)\(fp)
  508.         5.5511151231257827f-17 \(fr)(KCL/SUN and KCL/UST)\(fp)
  509.  
  510.     pi = 3.141592653589793\(ri 'pi)
  511. \(fr)
  512. See Chapter 12 of the \(fi)Common Lisp Reference Manual\(fr) for their
  513. meanings.
  514.  
  515. \(reserve 5)\(fg)
  516. 2.1.4. Complex Numbers\(set-page pp-2-1-4)
  517. \(fr)
  518. There are no implementation-dependent features for complex numbers.
  519.  
  520. \(reserve 5)\(fg)
  521. 2.2. Characters\(set-page pp-2-2)
  522.  
  523. 2.2.1. Standard Characters\(set-page pp-2-2-1)
  524. \(fr)
  525. KCL supports all standard and semi-standard characters listed in
  526. Section 2.2.1 of the \(fi)Common Lisp Reference Manual\(fr).  Non-printing
  527. characters have the following character code.
  528. \(reserve 10)
  529.     \(fi)Character        Code \(fr)(in octal)
  530.     \(fs)--------------------------------\(fp)
  531.     #\\Space        040
  532.     #\\Newline        012
  533.     #\\Backspace        010
  534.     #\\Tab        011
  535.     #\\Linefeed        012
  536.     #\\Page        014
  537.     #\\Return        015
  538.     #\\Rubout        177
  539. \(fr)
  540. Note that \(fp)#\\Linefeed\(fr) is synonymous with \(fp)#\\Newline\(fr) and
  541. thus is a member of \(fp)standard-char\(fr).  Other semi-standard characters
  542. are not members of \(fp)standard-char\(fr).
  543.  
  544.  
  545. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  546.  
  547. KCL/AOS uses \(fp)025\(fr) (in octal) as the character code of \(fp)#\\Backspace\(fr).
  548.  
  549. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  550.  
  551.  
  552. \(reserve 5)\(fg)
  553. 2.2.2. Line Divisions\(set-page pp-2-2-2)
  554. \(fr)
  555. Since KCL represents the \(fp)#\\Newline\(fr) character by a single
  556. code \(fp)12\(fr), problems with line divisions discussed in Section 2.2.2
  557. of the \(fi)Common Lisp Reference Manual\(fr) cause no problem in KCL.
  558.  
  559. \(reserve 5)\(fg)
  560. 2.2.3. Non-standard Characters\(set-page pp-2-2-3)
  561. \(fr)
  562. KCL supports no additional non-standard characters.
  563.  
  564. \(reserve 5)\(fg)
  565. 2.2.4. Character Attributes\(set-page pp-2-2-4)
  566. \(fr)
  567. The bit and font fields of KCL characters are always \(fp)0\(fr).
  568.  
  569.      Common Lisp constants related to characters
  570. have the following values in KCL.
  571. \(fp)
  572.     char-bits-limit = 1 \(ri 'char-bits-limit)
  573.     char-code-limit = 256 \(ri 'char-code-limit)
  574.     char-control-bit = 0 \(ri 'char-control-bit)
  575.     char-font-limit = 1 \(ri 'char-font-limit)
  576.     char-hyper-bit = 0 \(ri 'char-hyper-bit)
  577.     char-meta-bit = 0 \(ri 'char-meta-bit)
  578.     char-super-bit = 0 \(ri 'char-super-bit)
  579. \(fr)
  580. See Chapter 13 of the \(fi)Common Lisp Reference Manual\(fr) for their
  581. meanings.
  582.  
  583. \(reserve 5)\(fg)
  584. 2.2.5. String Characters\(set-page pp-2-2-5)
  585. \(fr)
  586. Since the bit and font fields of KCL characters are always \(fp)0\(fr),
  587. \(fp)string-char\(fr) is considered to be identical to \(fp)character\(fr).
  588.  
  589. \(reserve 5)\(fg)
  590. 2.3. Symbols\(set-page pp-2-3)
  591. \(fr)
  592. The print name of a symbol may consists of up to 16777216 (i.e., the value
  593. of \(fp)array-total-size-limit\(fr)) characters.  However, when a symbol is
  594. read, the number of characters (not counting escape characters)
  595. in the print name is limited to 2048.
  596.  
  597. \(reserve 5)\(fg)
  598. 2.4. Lists and Conses\(set-page pp-2-4)
  599. \(fr)
  600. There are no implementation-dependent features for lists and conses.
  601.  
  602. \(reserve 5)\(fg)
  603. 2.5. Arrays\(set-page pp-2-5)
  604. \(fr)
  605.      KCL arrays can have up to 64 ranks.
  606.  
  607.      When the value of the Common Lisp
  608. variable \(fp)*print-array*\(ri '*print-array*)\(fr) (see Section 22.1.6 of
  609. the \(fi)Common Lisp Reference
  610. Manual\(fr)) is \(fp)nil\(fr), then bit-vectors are printed as
  611. \(fp)#<a bit-vector>\(fr), other vectors are printed
  612. as \(fp)#<a vector>\(fr), and other arrays are printed as \(fp)#<an array>\(fr).
  613.  
  614.      Common Lisp constants related to arrays
  615. have the following values in KCL.
  616. \(fp)
  617.     array-dimension-limit = 16777216\(ri 'array-dimension-limit)
  618.     array-rank-limit = 64 \(ri 'array-rank-limit)
  619.     array-total-size-limit = 16777216 \(ri 'array-total-size-limit)
  620. \(fr)
  621. See Section 17.1 of the \(fi)Common Lisp Reference Manual\(fr) for
  622. their meanings.
  623.  
  624. \(reserve 5)\(fg)
  625. 2.5.1. Vectors\(set-page pp-2-5-1)
  626. \(fr)
  627. In KCL, array elements are represented in one of the six ways depending
  628. on the type of the array.
  629. \(reserve 8)\(fp)
  630.  \(fi)Array Type                    Element Representation\(fr)
  631.  \(fs)---------------------------------------------------------------\(fr)
  632.  \(fp)(array t)\(fr) and \(fp)(vector t)\(fr)            a cell pointer
  633.  \(fp)(array fixnum)\(fr) and \(fp)(vector fixnum)\(fr)        32 bit signed integer
  634.  \(fp)(array string-char)\(fr) and \(fp)string\(fr)            8 bit code
  635.  \(fp)(array short-float)\(fr) and \(fp)(vector short-float)\(fr)    32 bit floating point
  636.  \(fp)(array long-float)\(fr) and \(fp)(vector long-float)\(fr)    64 bit floating point
  637.  \(fp)(array bit)\(fr) and \(fp)bit-vector\(fr)            1 bit bit
  638.  
  639. \(reserve 5)\(fg)
  640. 2.5.2. Strings\(set-page pp-2-5-2)
  641. \(fr)
  642. A string may consists of up to 16777216 (i.e., the value
  643. of \(fp)array-total-size-limit\(fr)) characters.  However, when a string is
  644. read, the number of characters (not counting escape characters)
  645. in the string is limited to 2048.
  646.  
  647. \(reserve 5)\(fg)
  648. 2.5.3. Bit-Vectors\(set-page pp-2-5-3)
  649. \(fr)
  650. There are no implementation-dependent features for bit-vectors.
  651.  
  652. \(reserve 5)\(fg)
  653. 2.6. Hash Tables\(set-page pp-2-6)
  654. \(fr)
  655. All hash tables are printed as \(fp)#<a hash-table>\(fr).
  656.  
  657. \(reserve 5)\(fg)
  658. 2.7. Readtables\(set-page pp-2-7)
  659. \(fr)
  660. All readtables are printed as \(fp)#<a readtable>\(fr).
  661.  
  662. \(reserve 5)\(fg)
  663. 2.8. Packages\(set-page pp-2-8)
  664. \(fr)
  665.      The following packages are built into KCL.
  666. \(fp)
  667.     lisp  user  keyword  system  compiler
  668. \(fr)
  669. The \(fp)compiler\(fr) package contains symbols used by the KCL
  670. compiler.  Other packages are described in Section 11.6 of the \(fi)Common
  671. Lisp Reference Manual\(fr).  The \(fp)system\(fr) package has two nicknames
  672. \(fp)sys\(fr) and \(fp)si\(fr); \(fp)system:\(fi)symbol\(fr) may be
  673. written as \(fp)sys:\(fi)symbol\(fr) or \(fp)si:\(fi)symbol\(fr).  Other
  674. packages have no nicknames.
  675.  
  676.      Packages are printed as \(fp)#<\(fi)package-name\(fp) package>\(fr).
  677.  
  678. \(reserve 5)\(fg)
  679. 2.9. Pathnames\(set-page pp-2-9)
  680. \(fr)
  681.      KCL provides a \(fp)#\(fr) macro \(fp)#"\(fr) that reads a
  682. pathname:  \(fp)#"\(fi)string\(fr)\(fp)"\(fr) is equivalent
  683. to \(fp)(pathname\(ri 'pathname) "\(fi)string\(fp)")\(fr).  For example,
  684. \(fp)
  685.     #"foo.lsp"
  686. \(fr)
  687. is equivalent to
  688. \(fp)
  689.     (pathname\(ri 'pathname) "foo.lsp").
  690. \(fr)
  691. The same format is used when a pathname is printed.
  692.  
  693.      The initial value of the Common Lisp variable \(fp)*default-pathname-defaults*\(ri '*default-pathname-defaults*)\(fr)
  694. is \(fp)#""\(fr) (or, equivalently, \(fp)(pathname "")\(fr)).
  695.  
  696.      A pathname in the file system of Common Lisp
  697. consists of the following six elements:
  698. \(fp)
  699.     host  device  directory  name  type  version
  700. \(fr)
  701. Among these elements, KCL does not use \(fp)host\(fr), \(fp)device\(fr),
  702. and \(fp)version\(fr).  That is, when converting a namestring into a pathname, KCL
  703. turns these three elements into \(fp)nil\(fr).  Conversely, when converting a
  704. pathname into a namestring, KCL ignores these three
  705. elements.
  706.  
  707.      In the sequel, we explain how KCL converts a namestring into
  708. a pathname.
  709.  
  710.      If a namestring contains one or more periods '\(fp).\(fr)',
  711. the last period separates the namestring
  712. into the file name and the filetype.
  713. \(reserve 3)
  714.     \(fp)"foo.lsp"\(fr)
  715.         name:        \(fp)"foo"\(fr)
  716.         type:        \(fp)"lsp"
  717. \(reserve 3)
  718.     \(fp)"a.b.c"\(fr)
  719.         name:        \(fp)"a.b"\(fr)
  720.         type:        \(fp)"c"\(fr)
  721.  
  722. If a namestring ends with a period, the filetype
  723. becomes the null string.
  724. \(reserve 3)
  725.     \(fp)"foo."\(fr)
  726.         name:        \(fp)"foo"\(fr)
  727.         type:        \(fp)""\(fr) (null string)
  728.  
  729. If a namestring begins with a period, the file name becomes \(fp)nil\(fr).
  730. \(reserve 3)
  731.     \(fp)".lsp"\(fr)
  732.         name:        \(fp)nil\(fr)
  733.         type:        \(fp)"lsp"\(fr)
  734.  
  735. If a namestring contains no period, the filetype is \(fp)nil\(fr).
  736. \(reserve 3)
  737.     \(fp)"foo"\(fr)
  738.         name:        \(fp)"foo"\(fr)
  739.         type:        \(fp)nil\(fr)
  740. \(reserve 3)
  741. In a pathname, the file directory is represented as a list.
  742. \(reserve 4)
  743.     \(fp)"common/demo/foo.lsp"\(fr)
  744.         directory:    \(fp)("common"\(fr) \(fp)"demo")\(fr)
  745.         name:        \(fp)"foo"\(fr)
  746.         type:        \(fp)"lsp"\(fr)
  747.  
  748. If a namestring does not contain a directory,
  749. the directory component of the pathname is \(fp)nil\(fr).
  750. \(reserve 4)
  751.     \(fp)"foo.lsp"\(fr)
  752.         directory:    \(fp)nil\(fr)
  753.         name:        \(fp)"foo"\(fr)
  754.         type:        \(fp)"lsp"\(fr)
  755.  
  756. In a pathname, the root directory is represented
  757. by the keyword \(fp):root\(ri ':root)\(fr).
  758. \(reserve 4)
  759.     \(fp)"/usr/common/foo.lsp"
  760.     \(fr)    directory:     \(fp)(:root "usr" "common")\(fr)
  761.         name:        \(fp)"foo"\(fr)
  762.         type:        \(fp)"lsp"\(fr)
  763.  
  764. The abbreviation symbols '\(fp).\(fr)'
  765. and '\(fp)..\(fr)' may be used in a namestring.
  766. \(reserve 4)
  767.     \(fp)"./demo/queen.lsp"\(fr)
  768.         directory:    \(fp)(:current\(ri ':current) "demo")\(fr)
  769.         name:        \(fp)"queen"\(fr)
  770.         type:        \(fp)"lsp"\(fr)
  771. \(reserve 4)
  772.     \(fp)"../../demo/queen.lsp"\(fr)
  773.         directory:    \(fp)(:parent\(ri ':parent) :parent "demo")\(fr)
  774.         name:        \(fp)"queen"\(fr)
  775.         type:        \(fp)"lsp"\(fr)
  776.  
  777. \(fp):current\(fr) and \(fp):parent\(fr)
  778. represent the current directory and the parent
  779. directory, respectively.
  780.  
  781.     The part of a namestring after the last slash '\(fp)/\(fr)' is always
  782. regarded to represent the file name and the filetype.  In order to represent
  783. a pathname with both the name and the filetype \(fp)nil\(fr), end the
  784. pathname with a slash.
  785. \(reserve 4)
  786.     \(fp)"/usr/common/"\(fr)
  787.         directory:    \(fp)(:root "usr" "common")\(fr)
  788.         name:        \(fp)nil\(fr)
  789.         type:        \(fp)nil\(fr)
  790. \(reserve 4)
  791.     \(fp)"/usr/common/.lsp"\(fr)
  792.         directory:    \(fp)(:root "usr" "common")\(fr)
  793.         name:        \(fp)nil\(fr)
  794.         type:        \(fp)"lsp"\(fr)
  795.  
  796. '\(fp)*\(fr)' in the place of file name or filetype becomes \(fp):wild\(ri ':wild)\(fr).
  797. \(reserve 4)
  798.     \(fp)"*.lsp"\(fr)
  799.         name:        \(fp):wild\(fr)
  800.         type:        \(fp)"lsp"\(fr)
  801. \(reserve 4)
  802.     \(fp)"foo.*"\(fr)
  803.         name:        \(fp)"foo"\(fr)
  804.         type:        \(fp):wild\(fr)
  805.  
  806.  
  807. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  808.  
  809. In KCL/AOS, all the lower-case letters are turned into
  810. upper-case letters by pathname conversions.  Thus, for example,
  811. \(reserve 3)
  812.     \(fp)"foo.lsp"\(fr)
  813.         name:        \(fp)"FOO"\(fr)
  814.         type:        \(fp)"LSP"
  815. \(fr)
  816. KCL/AOS follows the convention of the AOS/VS file system:  The symbols
  817. '\(fp)/\(fr)',  '\(fp).\(fr)',  '\(fp)..\(fr)', and '\(fp)*\(fr)' in the examples
  818. above should be replaced by
  819. '\(fp):\(fr)',  '\(fp)=\(fr)',  '\(fp)^\(fr)', and '\(fp)-\(fr)',
  820. respectively, in KCL/AOS.
  821.  
  822. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  823.  
  824.  
  825. \(reserve 5)\(fg)
  826. 2.10. Streams\(set-page pp-2-10)
  827. \(fr)
  828. Streams are printed in the following formats.
  829.  
  830.  \(fp)#<input stream \(fi)file-name\(fp)>\(fr)
  831.      An input stream from the file \(fi)file-name\(fr).
  832.  
  833.  \(fp)#<output stream \(fi)file-name\(fp)>\(fr)
  834.      An output stream to the file \(fi)file-name\(fr).
  835.  
  836.  \(fp)#<string-input stream from \(fi)string\(fp)>\(fr)
  837.      An input stream generated by \(fp)(make-string-input-stream \(fi)string\(fp))\(fr)\(ri 'make-string-input-stream).
  838.  
  839.  \(fp)#<a string-output stream>\(fr)
  840.      An output stream generated by the function \(fp)make-string-output-stream\(fr)\(ri 'make-string-output-stream).
  841.  
  842.  \(fp)#<a two-way stream>\(fr)
  843.      A stream generated by the function \(fp)make-two-way-stream\(fr)\(ri 'make-two-way-stream).
  844.  
  845.  \(fp)#<an echo stream>\(fr)
  846.      A bidirectional stream generated by the function \(fp)make-echo-stream\(fr)\(ri 'make-echo-stream).
  847.  
  848.  \(fp)#<synonym stream to \(fi)symbol\(fp)>\(fr)
  849.      The stream generated by \(fp)(make-synonym-stream \(fi)symbol\(fp))\(fr)\(ri 'make-synonym-stream).
  850.  
  851.  \(fp)#<a concatenated stream>\(fr)
  852.      An input stream generated by the function \(fp)make-concatenated-stream\(fr)\(ri 'make-concatenated-stream).
  853.  
  854.  \(fp)#<a broadcast stream>\(fr)
  855.      An output stream generated by the function \(fp)make-broadcast-stream\(fr)\(ri 'make-broadcast-stream).
  856.  
  857. \(reserve 5)\(fg)
  858. 2.11. Random-States\(set-page pp-2-11)
  859. \(fr)
  860. KCL provides a \(fp)#\(fr) macro '\(fp)#$\(fr)' that reads a random
  861. state.  \(fp)#$\(fi)integer\(fr) is equivalent
  862. to \(fp)(make-random-state\(ri 'make-random-state)
  863. \(fi)integer\(fp))\(fr).  The same format is used when a random state is
  864. printed.
  865.  
  866. \(reserve 5)\(fg)
  867. 2.12. Structures\(set-page pp-2-12)
  868. \(fr)
  869. There are no implementation-dependent features for structures.
  870.  
  871. \(reserve 5)\(fg)
  872. 2.13. Functions\(set-page pp-2-13)
  873. \(fr)
  874. An interpreted function (including macro expansion functions) is
  875. represented in one of the following formats.
  876.  
  877. \(fp)(lambda \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr)\(bd)\(br)
  878. A lambda-expression with null lexical environment and with no implicit
  879. block around it.  This type of functions
  880. typically appear when
  881. \(fp)'(lambda \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr) is evaluated.
  882. \(endd)
  883.  
  884. \(fp)(lambda-block \(fi)block-name\(fr) \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr)\(bd)\(br)
  885. A lambda-expression with null lexical environment but with an implicit
  886. block around it.  This type of functions
  887. typically appear when
  888. \(fp)(defun\(ri 'defun) \(fi)function-name\(fr) \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr) is evaluated.  In this case, \(fi)block-name\(fr) is identical to \(fi)function-name\(fr).
  889. \(endd)
  890.  
  891. \(fp)(lambda-closure \(fi)env1\(fr) \(fi)env2\(fr) \(fi)env3\(fr) \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr)\(bd)\(br)
  892. A lambda-expression with lexical environments but with no implicit
  893. block around it.  This type of functions
  894. typically appear when
  895. \(fp)#'(lambda \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr) (or, equivalently,
  896. \(fp)(function\(ri 'function) (lambda \(fi)lambda-list\(fr) . \(fi)body\(fp)))\(fr) ) is
  897. evaluated.  \(fi)env1\(fr), \(fi)env2\(fr), and \(fi)env3\(fr) represent
  898. the variable bindings, the local function/macro definitions, and
  899. the tag/block-name establishments, respectively, at the time the closure
  900. was created.
  901. \(endd)
  902.  
  903. \(fp)(lambda-block-closure \(fi)env1\(fr) \(fi)env2\(fr) \(fi)env3\(fr) \(fi)block-name\(fr) \(fi)lambda-list\(fr) . \(fi)body\(fp))\(fr)\(bd)\(br)
  904. A lambda-expression with lexical environments and with an implicit
  905. block around it.  Local functions and local macros are represented in this
  906. format.  \(fi)env1\(fr), \(fi)env2\(fr), and \(fi)env3\(fr) represent
  907. the variable bindings, the local function/macro bindings, and
  908. the tag/block-name establishments, respectively, at the time the local
  909. function/macro was created by \(fp)flet\(ri 'flet)\(fr),
  910. \(fp)labels\(ri 'labels)\(fr), or \(fp)macrolet\(ri 'macrolet)\(fr).  The
  911. \(fi)block-name\(fr) is identical to the local function/macro name.
  912. \(endd)
  913.  
  914.      Compiled functions (including compiled macro-expansion
  915. functions) are printed in the following formats.
  916.  
  917.     \(fp)#<compiled-function \(fi)name\(fp)>\(fr)
  918.  or
  919.     \(fp)#<compiled-closure nil>\(fr)
  920.  
  921. Incidentally, the value of \(fp)(symbol-function \(fi)special-form-name\(fp))\(fr) is a
  922. list,
  923.  
  924.     \(fp)(special . \(fi)address\(fp))\(fr)
  925.  
  926. if \(fi)special-form-name\(fr) names a special form.
  927.  
  928.      Common Lisp constants related to functions
  929. have the following values in KCL.
  930. \(reserve 5)\(fp)
  931.     call-arguments-limit = 64 \(ri 'call-arguments-limit)
  932.     lambda-list-keywords = (&optional &rest &key &allow-other-keys &aux
  933.                             &whole &environment &body)\(ri 'lambda-list-keywords)
  934.     lambda-parameters-limit = 64 \(ri 'lambda-parameters-limit)
  935.     multiple-values-limit = 32 \(ri 'multiple-values-limit)
  936. \(fr)
  937. Refer to the \(fi)Common Lisp Reference Manual\(fr) for their meanings.
  938.  
  939. \(reserve 5)\(fg)
  940. 2.14. Unreadable Data Objects\(set-page pp-2-14)
  941. \(fr)
  942. There are no implementation-dependent features for unreadable data objects.
  943.  
  944. \(reserve 5)\(fg)
  945. 2.15. Overlap, Inclusion, and Disjointness of Types\(set-page pp-2-15)
  946. \(fr)
  947. In KCL, the types \(fp)number\(fr) and \(fp)array\(fr) are certainly
  948. subtypes of \(fp)common\(fr), since KCL does not extend the set of objects
  949. of these types.
  950.  
  951. \(fg) 
  952.  
  953. \(ce)Chapter 3. Input and Output
  954. \(set-page pp-3)
  955. \(fr)
  956. \(fg)
  957. 3.1. Read Macros\(set-page pp-3-1)
  958. \(fr)
  959.      The following \(fp)#\(fr) macros are introduced in KCL.
  960. \(reserve 2)
  961. \(fp)    #"    #"\(fi)string\(fp)"\(fr) reads a pathname.
  962. \(fp)        #"\(fi)string\(fr)\(fp)"\(fr) is equivalent to \(fp)(pathname\(ri 'pathname) "\(fi)string\(fp)")\(fr).
  963. \(reserve 2)
  964. \(fp)    #$    #$\(fi)integer\(fr) reads a random state.
  965. \(fp)        #$\(fi)integer\(fr) is equivalent to \(fp)(make-random-state\(ri 'make-random-state) \(fi)integer\(fp))\(fr).
  966.  
  967.      The \(fp)#\(fr) macro '\(fp)#,\(fr)' works as described
  968. in the \(fi)Common Lisp Reference Manual\(fr),
  969. only if it is included in a constant object.  The forms immediately
  970. after '\(fp)#,\(fr)' below will be evaluated when the compiled code is loaded.
  971. \(reserve 4)\(fp)
  972.     '#,x
  973.     '(a b c (d #,e f) g)
  974.     #(1 2 3 #,(+ a b c) 5 6)
  975.     #C(0.0 #,(exp 1))
  976. \(fr)
  977. Otherwise, the effect of using '\(fp)#,\(fr)' is unpredictable.  Note that, when an interpreted code is loaded, '\(fp)#,\(fr)'
  978. has the same effect as the \(fp)#\(fr) macro '\(fp)#.\(fr)'.
  979.  
  980. \(reserve 5)\(fg)
  981. 3.2. Input and Output Functions\(set-page pp-3-2)
  982. \(fr)
  983. The input and output functions of KCL almost follow
  984. the definitions in Chapter 22 of the \(fi)Common Lisp Reference
  985. Manual\(fr).  Most of the differences come from the fact that, in KCL,
  986. the input from the terminal is always in line mode
  987. and the binary I/O is not supported.
  988.  
  989.      In KCL, \(fp)*terminal-io*\(ri '*terminal-io*)\(fr) is a two-way
  990. stream from the standard input and to the standard output.  The echoing to the terminal is performed by the underlying
  991. operating system.  In particular, when a disk file is assigned to the standard
  992. output, nothing will be echoed at the terminal.
  993.  
  994.      Those functions that deviate from the definitions
  995. in the \(fi)Common Lisp Reference Manual\(fr) are listed below.
  996.  
  997.  
  998. \(fp)load\(ri 'load) \(fi)pathname\(fp) &key :print\(ri ':print) :verbose\(ri ':verbose) :if-does-not-exist\(ri ':if-does-not-exist)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  999. If \(fi)pathname\(fr) does not specify the filetype of the input file, then
  1000. \(fp)load\(fr) first tries to load a file with
  1001. the filetype \(fp).o\(fr), i.e., the fasl file (see
  1002. Chapter 6).  If it fails, then \(fp)load\(fr) tries to load a file with
  1003. the filetype \(fp).lsp\(fr).  KCL assumes that \(fp).lsp\(fr) is the standard
  1004. filetype for source files.  If it fails again, then \(fp)load\(fr) will load
  1005. the specified file with no filetype.
  1006.  
  1007. \(fp)load\(fr) recognizes a file as a fasl file if and only if
  1008. the filetype of the file is \(fp).o\(fr).  Other files are assumed to be source files.
  1009.  
  1010.  
  1011. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  1012.  
  1013. In KCL/AOS, the filetype of fasl files is \(fp).fasl\(fr) (see Chapter 6).
  1014. Therefore, if the \(fi)pathname\(fr) argument does not explicitly specify the
  1015. filetype, \(fp)load\(fr) first tries to load a file with the filetype
  1016. \(fp).fasl\(fr).  In addition,
  1017. \(fp)load\(fr) recognizes a file as a fasl file if and
  1018. only if the filetype of the file is \(fp).fasl\(fr).
  1019.  
  1020. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  1021.  
  1022. \(endd)
  1023.  
  1024. \(fp)open\(ri 'open)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1025. The argument to the keyword variable \(fp):element-type\(ri ':element-type)\(fr) is ignored
  1026. and \(fp):element-type\(fr) is always bound to the value
  1027. \(fp)string-char\(fr).
  1028. \(endd)
  1029.  
  1030. \(fp)close\(ri 'close)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1031. The keyword variable \(fp):abort\(ri ':abort)\(fr) is always ignored.
  1032. \(endd)
  1033.  
  1034. \(fp)listen\(ri 'listen)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1035. \(fp)listen\(fr) always returns \(fp)t\(fr).
  1036. \(endd)
  1037.  
  1038. \(fp)read-char-no-hang\(ri 'read-char-no-hang)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1039. \(fp)read-char-no-hang\(fr) is equivalent to \(fp)read-char\(ri 'read-char)\(fr).
  1040. \(endd)
  1041.  
  1042. \(fp)clear-input\(ri 'clear-input)\(fr)\(ra)[\(fi)Function\(fr)]
  1043. \(fp)clear-output\(ri 'clear-output)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1044. \(fp)clear-input\(fr) and \(fp)clear-output\(fr) simply
  1045. return \(fp)nil\(fr) without doing anything.
  1046. \(endd)
  1047.  
  1048. \(fp)read-byte\(ri 'read-byte)\(fr)\(ra)[\(fi)Function\(fr)]
  1049. \(fp)write-byte\(ri 'write-byte)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1050. These functions may operate on any stream.  They read or write a byte (8 bits) at a time.
  1051. \(endd)
  1052.  
  1053. \(fp)princ\(ri 'princ)\(fr)\(ra)[\(fi)Function\(fr)]
  1054. \(fp)write-char\(ri 'write-char)\(fr)\(ra)[\(fi)Function\(fr)]
  1055. \(fp)write-byte\(ri 'write-byte)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1056. These functions do not always flush the stream.  The stream is flushed when
  1057.  
  1058. 1. a newline character is written, or
  1059.  
  1060. 2. the input from the terminal is requested in case that these functions operate on \(fp)*terminal-io*\(ri '*terminal-io*)\(fr).
  1061. \(endd)
  1062.  
  1063. \(fg) 
  1064.  
  1065. \(ce)Chapter 4. Memory Management
  1066. \(set-page pp-4)
  1067. \(fr)
  1068. \(fg)
  1069. 4.1. Implementation Types\(set-page pp-4-1)
  1070. \(fr)
  1071. Each KCL object belongs to
  1072. one of the 22 \(fi)implementation types\(fr).  The
  1073. implementation types are shown in Table 4-1
  1074. with the corresponding Common Lisp data types.  In the table,
  1075. the compiled functions are divided into two implementation types;
  1076. \(fp)cfun\(fr) is the type of compiled functions without environment,
  1077. and \(fp)cclosure\(fr) is the type of compiled functions with environment
  1078. (i.e., the type of compiled closures).  \(fp)spice\(fr)
  1079. is the type of internal data used by KCL,
  1080. and does not correspond to any Common Lisp data type.
  1081. \(reserve 24)
  1082.         Table 4-1  Implementation Types
  1083.  
  1084.     \(fi)Implementation Type    Common Lisp Data Type\(fr)
  1085.     \(fs)----------------------------------------------------------------\(fr)
  1086. \(fp)    cons            cons
  1087.     fixnum            fixnum
  1088.     bignum            bignum
  1089.     ratio            ratio
  1090.     short-float        short-float
  1091.     long-float        long-float (= double-float = single-float)
  1092.     complex            complex
  1093.     character        character
  1094.     symbol            symbol
  1095.     package            package
  1096.     hash-table        hash-table
  1097.     array            (and array (not vector))
  1098.     vector            (and vector (not string) (not bit-vector))
  1099.     string            string
  1100.     bit-vector        bit-vector
  1101.     structure        structure
  1102.     stream            stream
  1103.     random-state        random-state
  1104.     readtable        readtable
  1105.     cfun            compiled-function \(fr)without environment\(fp)
  1106.     cclosure        compiled-function \(fr)with environment\(fp)
  1107.     spice            \(fr)none\(fp)
  1108.  
  1109. \(fr)
  1110.      Each object is represented by a cell allocated
  1111. in the heap area of the interpreter.  The
  1112. size of the cell is determined by the implementation type
  1113. of the object.
  1114.  
  1115.      The implementation types are classified
  1116. according to the size of the cells for the objects of the type, as shown in
  1117. Table 4-2.  The
  1118. size of the cells in the same type class is the same.
  1119. \(reserve 10)
  1120.         Table 4-2  Classification of Implementation Types
  1121.  
  1122.     \(fi)Class    Implementation Types\(fr)
  1123.     \(fs)----------------------------------------------------------------\(fr)
  1124.         1    \(fp)cons bignum ratio long-float complex\(fr)
  1125.         2    \(fp)fixnum short-float character random-state readtable spice\(fr)
  1126.         3    \(fp)symbol package\(fr)
  1127.         4    \(fp)array hash-table vector bit-vector stream pathname cclosure\(fr)
  1128.         5    \(fp)string cfun\(fr)
  1129.         6    \(fp)structure\(fr)
  1130.  
  1131.  
  1132.      For objects of the (implementation) types
  1133. \(fp)readtable\(fr), \(fp)symbol\(fr), \(fp)package\(fr),
  1134. \(fp)array\(fr), \(fp)hash-table\(fr),
  1135. \(fp)vector\(fr), \(fp)bit-vector\(fr), \(fp)stream\(fr), \(fp)cclosure\(fr),
  1136. \(fp)string\(fr), \(fp)cfun\(fr), and \(fp)structure\(fr),
  1137. the cell is simply a header of the object.  The
  1138. body of the object is allocated separately from the cell and is
  1139. managed in a different manner.  A
  1140. memory space occupied by the body of such an object
  1141. is called a \(fi)block\(fr).  A block is either \(fi)contiguous\(fr) or
  1142. \(fi)relocatable\(fr)
  1143. depending on the area in which it is allocated.  The
  1144. difference between the two areas will be explained below.  Table 4-3 lists
  1145. these types, along
  1146. with the contents of the body and the kind of the block.
  1147. \(reserve 16)
  1148.         Table 4-3  Types with Bodies
  1149.  
  1150.     \(fi)Type        Body            Block\(fr)
  1151.     \(fs)-----------------------------------------------------------\(fr)
  1152.     \(fp)readtable\(fr)    read table        contiguous
  1153.     \(fp)symbol\(fr)        symbol name        relocatable
  1154.     \(fp)package\(fr)        hash table        contiguous
  1155.     \(fp)array\(fr)        array body        relocatable or contiguous
  1156.     \(fp)hash-table\(fr)    hash table        relocatable
  1157.     \(fp)vector\(fr)        vector body        relocatable or contiguous
  1158.     \(fp)bit-vector\(fr)    bit-vector body        relocatable or contiguous
  1159.     \(fp)stream\(fr)        I/O buffer        contiguous
  1160.     \(fp)cclosure\(fr)    code            contiguous
  1161.     \(fp)string\(fr)        string body        relocatable or contiguous
  1162.     \(fp)cfun\(fr)        code            contiguous
  1163.     \(fp)structure\(fr)    structure body        relocatable
  1164.  
  1165.  
  1166.      Usually, the body of an array, a vector, a bit-vector, or a string
  1167. is allocated as a relocatable block.  In KCL, the
  1168. function \(fp)make-array\(ri 'make-array)\(fr) takes
  1169. an extra keyword argument \(fp):static\(ri ':static)\(fr).  If
  1170. the \(fp):static\(fr) argument is supplied with a non-\(fp)nil\(fr) value,
  1171. then the body of the array is allocated as a contiguous block.
  1172. \(endd)
  1173.  
  1174. \(reserve 5)\(fg)
  1175. 4.2. Heap and Relocatable Areas\(set-page pp-4-2)
  1176. \(fr)
  1177.     The memory space of KCL is divided into two parts:
  1178. the heap area and the relocatable area.  Both
  1179. areas occupy a contiguous space in the memory.
  1180.  
  1181.      Cells of KCL objects are allocated in the heap.  KCL
  1182. divides the heap into pages (1 page = 2048 bytes),
  1183. and each page consists of cells in the same type class (see Table 4-2).  Cells
  1184. in different type classes are allocated in different pages.  Some
  1185. blocks are also allocated in the heap:  They are called contiguous
  1186. blocks.  The pages for contiguous blocks
  1187. contain only contiguous blocks.  Thus each
  1188. page in the heap is either a page for cells in a particular type class,
  1189. or a page for contiguous blocks.  Blocks not in the heap are called
  1190. relocatable blocks and are allocated in the relocatable area.
  1191.  
  1192.      The user may specify the maximum number of pages
  1193. that can be allocated for each type class
  1194. by calling the KCL specific function \(fp)allocate\(ri 'allocate)\(fr).  There
  1195. is also a limit in the number of pages for contiguous blocks;
  1196. the limit can be altered by calling the KCL specific function
  1197. \(fp)allocate-contiguous-pages\(ri 'allocate-contiguous-pages)\(fr).  The
  1198. size of the relocatable area is specified
  1199. by the KCL specific function \(fp)allocate-relocatable-pages\(ri 'allocate-relocatable-pages)\(fr).  See Section 4.4 for these functions.
  1200.  
  1201.      In some installations of KCL,
  1202. the total amount of memory that KCL can use is limited.  In
  1203. such cases,
  1204. the entire memory may become exhausted,
  1205. before the maximum number of pages for each type class,
  1206. for contiguous blocks, or for the relocatable area
  1207. have not been allocated.
  1208.  
  1209.      The heap lies in the memory with the lower address
  1210. than the relocatable area
  1211. and there is a "hole" between the two areas (see Figure 4-1).  On the
  1212. request of a new page for heap, the page with the lowest address in the hole
  1213. is used.  When the hole is exhausted,
  1214. the relocatable area is shifted toward the higher address space
  1215. and a new hole of an appropriate size is created between the two areas.
  1216. \(reserve 6)
  1217.         Figure 4-1  Heap and Relocatable Area
  1218. \(fp)
  1219.      lower address                                  higher address
  1220.     \(fs)1--------------------2 - - - 2------------------3\(fp)
  1221.     |        heap        | hole  | relocatable area \(fs)|
  1222.     7--------------------8 - - - 8------------------9
  1223. \(fr)
  1224.  
  1225. \(reserve 5)\(fg)
  1226. 4.3. The Garbage Collector\(set-page pp-4-3)
  1227. \(fr)
  1228. The garbage collector of KCL has three levels
  1229. according to what it collects:
  1230. \(reserve 3)
  1231.     1. cells
  1232.     2. cells and relocatable blocks
  1233.     3. cells, relocatable blocks and contiguous blocks.
  1234.  
  1235. In levels 2 and 3,
  1236. the relocatable area is shifted to the higher address space to reserve
  1237. an appropriate number of pages in the hole.
  1238.  
  1239.      For each type class,
  1240. KCL keeps a free list of unused cells,
  1241. and when the free list is exhausted,
  1242. a new page is allocated, or the garbage collector is invoked,
  1243. depending on whether the maximum number of pages for that class
  1244. have been allocated or not.
  1245.  
  1246.      The garbage collector does not compactify the heap.  That is,
  1247. cells and contiguous blocks are never moved
  1248. to another place.  Moreover,
  1249. once a page is allocated for a particular type class
  1250. or for contiguous blocks,
  1251. that page will never be freed for other classes,
  1252. even if the entire page becomes a garbage.
  1253.  
  1254.      On the other hand, the relocatable area is compactified
  1255. during level 2 and level 3 garbage collection.  A relocatable
  1256. block is really relocatable.
  1257.  
  1258.      The garbage collector is automatically invoked in one of the following
  1259. situations.  The number in the parenthesis indicates the level of garbage
  1260. collection that is performed.
  1261.  
  1262.     * \(sm)The free list of a certain type class is exhausted
  1263. after the maximum number of pages have been allocated for that
  1264. type class (1).\(rm)
  1265.  
  1266.     * The hole is exhausted (2).
  1267.  
  1268.     * \(sm)The relocatable area is exhausted
  1269. after the maximum number of pages have
  1270. been allocated for relocatable area (2).\(rm)
  1271.  
  1272.     * \(sm)The contiguous blocks are exhausted
  1273. after the maximum number of pages have been allocated for contiguous blocks (3).\(rm)
  1274.  
  1275.      The garbage collector is also invoked by the following KCL
  1276. specific function.
  1277.  
  1278. \(fp)gbc\(ri 'gbc)\(fi) x\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1279. The garbage collector is invoked with the level specified
  1280. by \(fi)x\(fr).  If \(fi)x\(fr) is \(fp)nil\(fr),
  1281. the garbage collector is invoked for
  1282. level 1 garbage collection.  If \(fi)x\(fr) is \(fp)t\(fr),
  1283. it is invoked for level 3 garbage collection.  Otherwise,
  1284. it is invoked level 2 garbage collection.
  1285. \(endd)
  1286.  
  1287. \(reserve 5)\(fg)
  1288. 4.4. Allocation Functions\(set-page pp-4-4)
  1289. \(fr)
  1290. The following functions are used to set or inspect
  1291. the (maximum) number of pages for each type class, for contiguous blocks,
  1292. or for relocatable blocks.
  1293.  
  1294. \(fp)allocate\(ri 'allocate)\(fi) type number\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1295. Sets the maximum number of pages for the type class of the implementation type
  1296. \(fi)type\(fr) to \(fi)number\(fr).  If more than \(fi)number\(fr) pages have already been allocated,
  1297. an error is signalled.
  1298. \(endd)
  1299.  
  1300. \(fp)allocated-pages\(ri 'allocated-pages)\(fi) type\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1301. Returns the number of pages currently allocated
  1302. for the type class of the implementation type \(fi)type\(fr).
  1303. \(endd)
  1304.  
  1305. \(fp)maximum-allocatable-pages\(ri 'maximum-allocatable-pages)\(fi) type\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1306. Returns the current maximum number of pages
  1307. for tye type class of the implementation type \(fi)type\(fr).
  1308. \(endd)
  1309.  
  1310. \(fp)allocate-contiguous-pages\(fi) number\(fr)\(ri 'allocate-contiguous-pages)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1311. Sets the maximum number of pages for contiguous blocks to \(fi)number\(fr).
  1312. \(endd)
  1313.  
  1314. \(fp)allocated-contiguous-pages\(ri 'allocated-contiguous-pages)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1315. Returns the number of pages allocated for contiguous blocks.
  1316. \(endd)
  1317.  
  1318. \(fp)maximum-contiguous-pages\(ri 'maximum-contiguous-pages)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1319. Returns the current maximum number of pages for contiguous blocks.
  1320. \(endd)
  1321.  
  1322. \(fp)allocate-relocatable-pages\(fi) number\(fr)\(ri 'allocate-relocatable-pages)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1323. Sets the maximum number of pages for relocatable blocks
  1324. to \(fi)number\(fr).  The relocatable area is expanded to \(fi)number\(fr)
  1325. pages immediately.  Therefore, "the current maximum number" and "the
  1326. number of pages allocated" have the same meanings for relocatable blocks.
  1327. \(endd)
  1328.  
  1329. \(fp)allocated-relocatable-pages\(ri 'allocated-relocatable-pages)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1330. Returns the number of pages allocated for relocatable blocks.
  1331. \(endd)
  1332.  
  1333.      If the pages for a particular type class is exhausted
  1334. after the maximum number of pages for that class have been allocated,
  1335. and if there remain no free cells (actually, if there remain very few cells),
  1336. KCL behaves as directed by the value of the KCL specific
  1337. variable \(fp)*ignore-maximum-pages*\(ri '*ignore-maximum-pages*)\(fr).  If
  1338. the value is \(fp)nil\(fr),
  1339. then KCL signals a correctable error and enters the break loop.  The
  1340. user can reset the maximum number by calling \(fp)allocate\(fr)
  1341. and then continue the execution of the program by typing \(fp):r\(fr).
  1342. \(reserve 16)
  1343.      Example:
  1344. \(fp)
  1345.     >(make-list 100000)
  1346.  
  1347.     Correctable error: The storage for CONS is exhausted.
  1348.                        Currently, 531 pages are allocated.
  1349.                        Use ALLOCATE to expand the space.
  1350.     Signalled by MAKE-LIST.
  1351.  
  1352.     Broken at FUNCALL.
  1353.     >>(ALLOCATE 'CONS 1000)
  1354.     t
  1355.  
  1356.     >>:r
  1357.  
  1358.     (nil nil nil nil nil nil nil nil nil nil ............
  1359. \(fr)
  1360. The user can also reset the maximum number of pages
  1361. for relocatable blocks and for contiguous blocks in a similar manner.
  1362. On the other hand, if
  1363. the value of \(fp)*ignore-maximum-pages*\(ri '*ignore-maximum-pages*)\(fr)
  1364. is non-\(fp)nil\(fr),
  1365. then KCL automatically increments the maximum number of pages for the
  1366. class by 50 percent.  The initial value of \(fp)*ignore-maximum-pages*\(ri '*ignore-maximum-pages*)\(fr) is
  1367. \(fp)t\(fr).
  1368.  
  1369. \(reserve 5)\(fg)
  1370. 4.5. Storage Information\(set-page pp-4-5)
  1371. \(fr)
  1372. \(fp)room\(ri 'room) &optional\(fi) x\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1373. The function \(fp)room\(fr) prints the storage information.  The argument
  1374. \(fi)x\(fr) is simply ignored and
  1375. the output of \(fp)room\(fr) is always in the same
  1376. format.  \(fp)room\(fr) prints the following information:
  1377. \(reserve 19)
  1378.     * for each type class
  1379.         * \(sm)the number of pages so-far allocated for the type class\(rm)
  1380.         * the maximum number of pages for the type class
  1381.         * \(sm)the percentage of used cells to cells so-far allocated\(rm)
  1382.         * \(sm)the number of times the garbage collector has been called to collect cells of the type class\(rm)
  1383.         * the implementation types that belongs to the type class
  1384.     * the number of pages actually allocated for contiguous blocks
  1385.     * the maximum number of pages for contiguous blocks
  1386.     * \(sm)the number of times the garbage collector has been called to collect contiguous blocks\(rm)
  1387.     * the number of pages in the hole
  1388.     * the maximum number of pages for relocatable blocks
  1389.     * \(sm)the number of times the garbage collector has been called to collect relocatable blocks\(rm)
  1390.     * the total number of pages allocated for cells
  1391.     * the total number of pages allocated
  1392.     * the number of available pages
  1393.     * the number of pages KCL can use.
  1394.  
  1395. The number of times the garbage collector has been called
  1396. is not shown, if the number is zero.
  1397.  
  1398.      In the following example,
  1399. the maximum of \(fp)531\(fr) pages have already been allocated
  1400. for the type class to which \(fp)cons\(fr) belongs, but only 16.9 percent
  1401. of the cells are actually used.  The garbage collector was
  1402. once invoked to collect cells in this type class.
  1403. \(reserve 17)\(fp)
  1404.  >(room)
  1405.   531/531   16.9%  1  cons bignum ratio long-float complex
  1406.     3/52    10.4%     fixnum short-float character random-state
  1407.                       readtable spice
  1408.    47/65    73.6%     symbol package
  1409.     3/71    32.4%     array hash-table vector bit-vector stream
  1410.                       pathname cclosure
  1411.    46/96    98.8%     string cfun
  1412.     1/32     2.3%     structure
  1413.  
  1414.    17/512             contiguous (3 blocks)
  1415.       14              hole
  1416.       50    47.4%  2  relocatable
  1417.  
  1418.    631 pages for cells
  1419.    712 total pages
  1420.  14840 pages available
  1421.  16384 maximum pages
  1422.  
  1423.  >
  1424. \(fr)
  1425. \(endd)
  1426.  
  1427. \(fg) 
  1428.  
  1429. \(ce)Chapter 5. Debugging Facilities
  1430. \(set-page pp-5)
  1431. \(fr)
  1432. \(fg)
  1433. 5.1. The Tracer\(set-page pp-5-1)
  1434. \(fr)
  1435. The Tracer causes selected functions to be traced.  When such a traced function is invoked, it prints
  1436.  
  1437.     \(fi)level\(fp) > (\(fi)name\(fp) \(fi)arg1\(fp) \(fi)...\(fp) \(fi)argn\(fp))\(fr)
  1438.  
  1439. On return from a traced function, it prints
  1440.  
  1441.     \(fp)< \(fi)level\(fp) (\(fi)name\(fp) \(fi)value1\(fp) \(fi)...\(fp) \(fi)valuen\(fp))\(fr)
  1442.  
  1443. \(fi)name\(fr) is the name of the traced function,
  1444. \(fi)arg\(fr)s are the arguments,
  1445. and \(fi)value\(fr)s are the return values.  \(fi)level\(fr) is a number which is incremented each time
  1446. a traced function is invoked and is decremented at the completion of the
  1447. invocation.  Trace print-outs are indented according to the \(fi)level\(fr).
  1448.  
  1449.      In the current version of KCL, macros and special forms cannot be traced.
  1450.  
  1451.  
  1452. \(fp)trace\(ri 'trace) \(fr){\(fi)function-name\(fr)}*\(ra)[\(fi)Macro\(fr)]\(bd)
  1453. Causes one or more functions to be traced.  \(fi)function-name\(fr)s must be
  1454. symbols and they are not evaluated.  If a function is called from
  1455. a compiled function, the call may not produce trace
  1456. print-outs.  If this is the case, the simplest way to get
  1457. trace print-outs is to recompile the caller with
  1458. a \(fp)notinline\(ri 'notinline)\(fr) declaration for the called function (see
  1459. Chapter 7).  \(fp)trace\(fr) returns a name list of those functions that were
  1460. traced by the call to \(fp)trace\(fr).  If no \(fi)function-name\(fr) is
  1461. given, \(fp)trace\(fr) simply returns
  1462. a name list of all the currently traced functions.
  1463. \(endd)
  1464.  
  1465. \(fp)untrace\(ri 'untrace) \(fr){\(fi)function-name\(fr)}*\(ra)[\(fi)Macro\(fr)]\(bd)
  1466. Causes the specified functions to be not traced any more.  \(fi)function-name\(fr)s must be symbols and they are not evaluated.  \(fp)untrace\(fr) returns a name list of those functions that were untraced by
  1467. the call to \(fp)untrace\(fr).  If no \(fi)function-name\(fr) is given, \(fp)untrace\(fr) will untrace
  1468. all the currently traced functions and will return a list of their names.
  1469. \(endd)
  1470. \(reserve 5)\(fg)
  1471. 5.2. The Stepper\(set-page pp-5-2)
  1472. \(fr)
  1473. \(fp)step\(ri 'step) \(fi)form\(fr)\(ra)[\(fi)Macro\(fr)]\(bd)
  1474. Starts evaluating the \(fi)form\(fr) in the single-step mode.  In this mode, before any form is evaluated,
  1475. the Stepper will print the form and prompt the user
  1476. for a Stepper command.  The Stepper binds
  1477. the two variables \(fp)*print-level*\(ri '*print-level*)\(fr) and \(fp)*print-length*\(ri '*print-length*)\(fr)
  1478. both to \(fp)2\(fr), so that the current form may not occupy too much
  1479. space on the screen.  A Stepper command will be executed when the user types
  1480. the single character for the command followed by the required
  1481. arguments, if any, and presses the newline key.  If the user presses the newline key without having typed any character,
  1482. then the Stepper will assume that the Stepper command
  1483. \(fp)n\(fr) was abbreviated.
  1484.  
  1485. The Stepper commands are:
  1486. \(br)
  1487. \(fp)n\(fr)    \(sm)Next.  Evaluates the current form in the single-step mode.\(rm)
  1488.  
  1489. \(fp)s\(fr)    \(sm)Skip.  Evaluates the current form in the ordinary mode.  The single-step mode will be resumed at completion
  1490. of the evaluation.\(rm)
  1491.  
  1492. \(fp)p\(fr)    \(sm)Print.  Pretty-prints the current form and then prompts again.\(rm)
  1493.  
  1494. \(fp)f\(fr) \(fi)fn\(fr)    \(sm)Function.  Evaluates the current form in the ordinary mode until the specified
  1495. function \(fi)fn\(fr) is invoked.  If the specified function is not invoked at all, then this command has the same effects as the \(fp)q\(fr) command below.\(rm)
  1496.  
  1497. \(fp)q\(fr)    \(sm)Quit.  Evaluates the current form and any other forms in the ordinary mode.\(rm)
  1498.  
  1499. \(fp)e\(fr) \(fi)form\(fr)    \(sm)Eval.  Evaluates the specified form in the ordinary mode and prints the resulted values.  Then prompts again with the same current form.\(rm)
  1500.  
  1501. \(fp)?\(fr)    \(sm)Help.  Lists the Stepper commands.\(rm)
  1502. \(endd)
  1503. \(reserve 5)\(fg)
  1504. 5.3.  Errors\(set-page pp-5-3)
  1505. \(fr)
  1506. \(fp)*break-enable*\(ri '*break-enable*)\(fr)\(ra)[\(fi)Variable\(fr)]\(bd)
  1507. This variable is used to determine whether to enter the
  1508. break loop (see Section 5.4) when an error occurs.  Even the function
  1509. \(fp)break\(ri 'break)\(fr) checks this variable.  Initially, this variable is set to \(fp)t\(fr), and thus
  1510. an error will invoke the break loop.  If the value is \(fp)nil\(fr),
  1511. functions that cause fatal errors, such as \(fp)error\(ri 'error)\(fr),
  1512. will just print an error message and control will return to the top-level loop
  1513. (or to the current break loop, if already in the break loop).  Functions
  1514. that cause correctable errors, such as \(fp)cerror\(ri 'cerror)\(fr),
  1515. will print an error message and a "continue message", and
  1516. control will return to the next form.  In KCL, backtrace is not part of an error message, but
  1517. a break loop command will print backtrace.  Therefore, if \(fp)*break-enable*\(ri '*break-enable*)\(fr) is \(fp)nil\(fr),
  1518. no backtrace appears on the screen.
  1519.  
  1520. When the break loop is entered, \(fp)*break-enable*\(ri '*break-enable*)\(fr)
  1521. will be bound to \(fp)nil\(fr).
  1522. \(endd)
  1523. \(reserve 5)\(fg)
  1524. 5.4.  The Break Loop\(set-page pp-5-4)
  1525. \(fr)
  1526. The break loop is a read-eval-print loop similar to the top-level loop.  In addition to ordinary Lisp forms, the break loop accepts
  1527. various commands with which the user can inspect and modify the
  1528. state of the program execution.  Each break loop command is identified
  1529. with a keyword (i.e., a symbol in the \(fp)keyword\(fr)
  1530. package).  A break loop command is executed when the user inputs a list
  1531. whose first element is the keyword that identifies the command.  The rest of the list is the arguments to the command.  They are evaluated before passed to the command.  If the command
  1532. needs no arguments, then the user may input only the keyword.  It is an error if the given keyword does not identify any command.  Any other input to the break loop is regarded as an
  1533. ordinary Lisp form; the form will be evaluated and the resulted values
  1534. will be printed on the terminal.
  1535.  
  1536.      There can be several instances of the break loop at the same time, and
  1537. each such instance is identified by a \(fi)level
  1538. number\(fr).  When the break loop is entered during execution in the
  1539. top-level loop,
  1540. the break loop instance is given the level number \(fp)1\(fr).  The break loop instance that is entered from the level \(fi)n\(fr)
  1541. break loop is given the level number \(fi)n\(fp)+1\(fr).  The prompt of the level \(fi)n\(fr) break loop is \(fi)n\(fp)+1\(fr)
  1542. consecutive \(fp)>\(fr)'s, occasionally prefixed with the name of
  1543. the current package.
  1544.  
  1545.      The break loop keeps track of the invocation sequence of functions
  1546. (including special forms and macro expansion functions),
  1547. which led up to the break loop
  1548. from the previous break loop (or from the top-level loop,
  1549. if the current break loop is level \(fp)1\(fr)).  The invocation sequence is maintained in a pushdown stack of \(fi)event\(fr)s.  An event consists of an \(fi)event function\(fr) and an \(fi)event
  1550. environment\(fr).  An event function is:
  1551.  
  1552.     1. \(sm)an interpreted (i.e., not compiled) function (global function, local function, lambda-expression, or closure),\(rm)
  1553.     2. \(sm)a special form within an interpreted function,\(rm)
  1554.     3. \(sm)a macro expansion function called from an interpreted function,\(rm)
  1555.     4. \(sm)a compiled function called from an interpreted function, or\(rm)
  1556.     5. \(sm)a compiled function called from another compiled
  1557. function which was compiled while the \(fp)safety\(ri 'safety)\(fr) optimize
  1558. level is \(fp)3\(fr) or with a \(fp)notinline\(ri 'notinline)\(fr)
  1559. declaration for the called function (see Chapter 7).\(rm)
  1560.  
  1561.      An event is pushed on the event stack when execution of its event
  1562. function begins, and is poped away at the completion of the
  1563. execution.  An event environment is the 'environment' of the
  1564. event function at the time the next event is pushed.  Actually, an event
  1565. environment is a pointer to
  1566. the main stack of KCL.  For each interpreted event function (i.e., event
  1567. function in classes 1, 2, and 3),
  1568. the pointer points to the first entry of the three contiguous
  1569. main stack entries that hold the lexical environment of the event
  1570. function.  For each compiled event function (i.e., event function in classes
  1571. 4 and 5),
  1572. the pointer is set to the first entry of the
  1573. main stack area that is used locally by the compiled code.  In most cases,
  1574. the first argument to the compiled function is saved in the
  1575. first entry, the second argument in the second entry, and so on.  The local
  1576. variables of the function are allocated in the entries following the
  1577. arguments.  However, this is not always the case.  Refer to Section 7.3 for
  1578. variable allocations in compiled functions.
  1579.  
  1580.      By break level commands,
  1581. the user can choose one of the events as \(fi)the current event\(fr).  If the
  1582. current event function is an interpreted event function, then
  1583. the break loop evaluates Lisp forms
  1584. in the lexical environment retrieved from the event
  1585. environment.  In particular, local variables may be referenced
  1586. by the variable names,
  1587. local functions and local macros may be invoked as usual, established
  1588. blocks may be exited from, and
  1589. tags may be used as the destination of \(fp)go\(ri 'go)\(fr).  If the current function is a compiled function,
  1590. Lisp forms are evaluated in the null environment.
  1591.  
  1592.      Within the break loop, each event is represented by \(fi)the event
  1593. symbol\(fr).  The \(fp):backtrace\(fr)
  1594. command, for example, lists events in terms of their event symbols.  If the event function is a named function (global or local)
  1595. or a macro expansion function, then the function or macro name
  1596. is used as the event symbol.  If the event function is a special form,
  1597. then the name of the special form is used.  If the event function is
  1598. a lambda-expression (or a closure), then the symbol \(fp)lambda\(fr) (or
  1599. \(fp)lambda-closure\(fr)) is used.
  1600.  
  1601.      To suppress unnecessary information,
  1602. the user can hide (or make invisible) some of the events.  Invisible events do not appear in the backtrace, for example.  Initially, only those events are invisible whose event symbols belong to the
  1603. system internal package \(fp)system\(fr).  When the break loop is entered,
  1604. the last visible event becomes the current event.
  1605.  
  1606.      The break loop commands are described below.  Some of the commands
  1607. allows abbreviation in the keywords that identify them.  For example, the user may abbreviate \(fp):current\(fr) as \(fp):c\(fr).  The break loop commands return no values at all.
  1608.  
  1609.  
  1610. \(fp):current\(ri ':current)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1611. \(fp):c\(ri ':c)\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1612. Prints the event symbol of the current event.
  1613. \(endd)
  1614.  
  1615. \(fp):previous\(ri ':previous) &optional \(fi)n\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1616. \(fp):p\(ri ':p) &optional \(fi)n\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1617. Makes the \(fi)n\(fr)-th previous visible event the
  1618. new current event.  Invisible events are not counted.  If there are less than \(fi)n\(fr) previous
  1619. events, then the first visible event in the invocation sequence
  1620. becomes the new current event.  \(fi)n\(fr) must be a positive integer and the default is \(fp)1\(fr).
  1621. \(endd)
  1622.  
  1623. \(fp):next\(ri ':next) &optional \(fi)n\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1624. \(fp):n\(ri ':n) &optional \(fi)n\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1625. Makes the \(fi)n\(fr)-th next visible event the
  1626. new current event.  If there are less than \(fi)n\(fr) next events,
  1627. then the last visible event in the invocation sequence
  1628. becomes the new current event.  \(fi)n\(fr) must be a positive integer and the default is \(fp)1\(fr).
  1629. \(endd)
  1630.  
  1631. \(fp):backtrace\(ri ':backtrace)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1632. \(fp):b\(ri ':b)\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1633. Prints the event symbols of all visible events in order.  The symbol of
  1634. the current event is printed
  1635. in upper-case letters and the event symbols of other events are in lower-cases.
  1636. \(endd)
  1637.  
  1638. \(fp):help\(ri ':help)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1639. \(fp):h\(ri ':h)\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1640. Lists the break loop commands.
  1641. \(endd)
  1642.  
  1643. \(fp):quit\(ri ':quit) &optional \(fi)n\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1644. \(fp):q\(ri ':q) &optional \(fi)n\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1645. Returns control to the level \(fi)n\(fr) break loop.  If \(fi)n\(fr) is \(fp)0\(fr) or if \(fi)n\(fr) is omitted, then
  1646. control will return to the top-level loop.  \(fi)n\(fr) must be a non-negative integer smaller than
  1647. the current break level.
  1648. \(endd)
  1649.  
  1650. \(fp):resume\(ri ':resume)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1651. \(fp):r\(ri ':r)\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1652. Returns control to the caller of the break loop.  If the break loop has been
  1653. entered from \(fp)cerror\(ri 'cerror)\(fr),
  1654. \(fp)cerror\(fr) returns \(fp)nil\(fr) as its value and
  1655. control will resume at that point.  Otherwise, this command returns control to the previous break loop (or to
  1656. the top-level loop, if the current break level is 1).
  1657. \(endd)
  1658.  
  1659. \(fp):variables\(ri ':variables)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1660. \(fp):v\(ri ':v)\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1661. Prints the names of the bound variables in the current
  1662. environment.  To see the value of a bound variable, just type the
  1663. variable name.
  1664. \(endd)
  1665.  
  1666. \(fp):functions\(ri ':functions)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1667. Prints the names of the local functions and local macros
  1668. in the current environment.  To see the definition of a local function
  1669. or macro, use the \(fp)function\(fr) special form in the
  1670. usual way.  That is, \(fp)(function \(fi)name\(fp))\(fr) will return the
  1671. definition of the local function or macro
  1672. whose name is \(fi)name\(fr).  Local functions and local macros
  1673. may be invoked as usual.
  1674. \(endd)
  1675.  
  1676. \(fp):blocks\(ri ':blocks)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1677. Prints the names of the blocks established in the current
  1678. environment.  If a block \(fi)block\(fr) is established,
  1679. then the \(fp)return-from\(ri 'return-from)\(fr) form
  1680. \(fp)(return-from \(fi)block\(fp) \(fi)value\(fp))\(fr)
  1681. works as usual.  That is, the block form that established \(fi)block\(fr)
  1682. will return \(fi)value\(fr) as its value and control will resume at
  1683. that point.
  1684. \(endd)
  1685.  
  1686. \(fp):tags\(ri ':tags)\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1687. Prints the tags established in the current environment.  If a tag \(fi)tag\(fr) is established,
  1688. then the \(fp)go\(ri 'go)\(fr) form
  1689. \(fp)(go \(fi)tag\(fp))\(fr) works as usual.  That is, control will resume at the position of \(fi)tag\(fr) in the
  1690. surrounding \(fp)tagbody\(ri 'tagbody)\(fr).
  1691. \(endd)
  1692.  
  1693. \(fp):local\(ri ':local) &optional \(fi)n\(fr)\(ra)[\(fi)Break Loop Command\(fr)]
  1694. \(fp):l\(ri ':l) &optional \(fi)n\(fr)\(ra)[\(fi)Abbreviated Break Loop Command\(fr)]\(bd)
  1695. If \(fi)n\(fr) is \(fp)0\(fr) or if it is omitted,
  1696. then this command prints the value stored in the main stack entry
  1697. that is pointed to by the current event environment.  \(fi)n\(fr) is an offset from that entry.  If \(fi)n\(fr) is positive, then the value of
  1698. the \(fi)n\(fr)-th next (i.e., toward the top of the main stack) entry
  1699. is printed.  If \(fi)n\(fr) is negative, then the value of
  1700. the | \(fi)n\(fr) |-th previous (i.e., toward the bottom of the main stack) entry
  1701. is printed.  \(fi)n\(fr) must be an integer.  It is an error if the specified entry does not lie between the bottom and
  1702. the top of the stack.
  1703. \(endd)
  1704.  
  1705. \(fp):hide\(ri ':hide) \(fi)symbol\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1706. Hides all events whose event symbol is \(fi)symbol\(fr).  In particular, by \(fp)(:hide 'lambda)\(fr) and
  1707. \(fp)(:hide 'lambda-closure)\(fr), all events become invisible
  1708. whose event functions are lambda-expressions and closures, respectively.  If the event symbol of the current event happens to be \(fi)symbol\(fr),
  1709. then the last previous visible event will become the new current event.  \(fi)symbol\(fr) must be a symbol.
  1710.  
  1711. Events of \(fp)eval\(ri 'eval)\(fr) and \(fp)evalhook\(ri 'evalhook)\(fr) may never become
  1712. invisible and attempts to hide them are simply ignored.  It is always
  1713. the case that the first event function is either \(fp)eval\(fr)
  1714. or \(fp)evalhook\(fr).  Keeping both of them visible is the simplest way
  1715. to avoid the silly attempts of the user to hide all events.
  1716. \(endd)
  1717.  
  1718. \(fp):hide-package\(ri ':hide-package) \(fi)package\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1719. Hides all events whose event symbol belongs to the package
  1720. \(fi)package\(fr).  \(fi)package\(fr) may be any object that represents a package, i.e., a package object, a symbol, or a string.  If the event symbol
  1721. of the current event happens to belong to the
  1722. package \(fi)package\(fr),
  1723. then the last previous visible event will
  1724. become the new current event.  Even if \(fp)lisp\(fr) package was
  1725. specified as \(fi)package\(fr),
  1726. events of \(fp)eval\(ri 'eval)\(fr) and \(fp)evalhook\(ri 'evalhook)\(fr)
  1727. do not become invisible.  See the description of \(fp):hide\(fr) above.
  1728. \(endd)
  1729.  
  1730. \(fp):unhide\(ri ':unhide) \(fi)symbol\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1731. \(fp):unhide\(fr) is the inverse command of \(fp):hide\(fr).  If, however, \(fi)symbol\(fr) belongs to one of the \(fp):hide-package\(fr)d
  1732. packages, events of \(fi)symbol\(fr) become visible only after the
  1733. package is \(fp):unhide-package\(fr)'d.  \(fi)symbol\(fr) must be a symbol.
  1734. \(endd)
  1735.  
  1736. \(fp):unhide-package\(ri ':unhide-package) package\(fr)\(ra)[\(fi)Break Loop Command\(fr)]\(bd)
  1737. \(fp):unhide-package\(fr) is the inverse
  1738. command of \(fp):hide-package\(fr).  However, an event whose event symbol belongs to \(fi)package\(fr) becomes
  1739. visible only after the symbol is \(fp):unhide\(fr)'d, if the symbol
  1740. was \(fp):hide\(fr)'d before.  \(fi)package\(fr) may be any object that represents a package, i.e., a package object, a symbol, or a string.
  1741. \(endd)
  1742.  
  1743.      Example:
  1744. \(fp)
  1745.     >(defun fact (x) (if (= x 0) one (* x (fact (1- x)))))
  1746.     fact            ;;; \(fr)Wrong definition for \(fp)fact\(fr), the factorial.\(fp)
  1747.     
  1748.     >(fact 6)        ;;; \(fr)Tries to calculate factorial 6.\(fp)
  1749.  
  1750.     Error: The variable ONE is unbound.
  1751.     Error signalled by IF.
  1752.     
  1753.     Broken at IF.        ;;; \(fr)Enters the break-loop.\(fp)
  1754.     >>:h            ;;; \(fr)Help.\(fp)
  1755.     :c(urrent)        Shows the current function.
  1756.     :p(revious)        To the previous function.
  1757.     :n(ext)            To the next function.
  1758.     :b(acktrace)        Prints backtrace.
  1759.     :h(elp)            Help.
  1760.     :q(uit)            Returns to top-level.
  1761.     :r(esume)        Returns to the caller of break-level.
  1762.     :l(ocal)        Shows the n-th local value on the stack.
  1763.     :v(ariables)        Shows local variables.
  1764.     :functions        Shows local functions.
  1765.     :blocks            Shows block names.
  1766.     :tags            Shows tags.
  1767.     :(un)hide(-package)    (Un)hide a function (or a package).
  1768.     
  1769.     >>:b            ;;; \(fr)Backtrace.\(fp)
  1770.     Backtrace: eval > fact > if > fact > if > fact > if > fact > if >
  1771.     fact > if > fact > if > fact > IF
  1772.     
  1773.     >>:p            ;;; \(fr)Moves to the previous event.\(fp)
  1774.     Broken at FACT.
  1775.     
  1776.     >>:b            ;;; \(fr)Now inside of \(fp)fact\(fr) but outside of \(fp)if\(fr).\(fp)
  1777.     Backtrace: eval > fact > if > fact > if > fact > if > fact > if >
  1778.     fact > if > fact > if > FACT > if
  1779.     
  1780.     >>:v            ;;; \(fr)Shows local variables.\(fp)
  1781.     Local variables: x.
  1782.     
  1783.     >>x            ;;; \(fr)The value of \(fp)x\(fr) is \(fp)0\(fr).\(fp)
  1784.     0
  1785.     
  1786.     >>:blocks        ;;; \(fr)Shows blocks.\(fp)
  1787.     Block names: fact.
  1788.     
  1789.     >>(return-from fact 1)    ;;; \(fr)Returns from the \(fp)fact\(fr) block with value \(fp)1\(fr).\(fp)
  1790.     720            ;;; \(fr)Now the correct answer.\(fp)
  1791.  
  1792.     >            ;;; \(fr)Top-level.
  1793. \(fr)
  1794. \(reserve 5)\(fg)
  1795. 5.5. Describe and Inspect\(set-page pp-5-5)
  1796. \(fr)
  1797. \(fp)describe\(ri 'describe) \(fi)object\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1798. Prints the information about \(fi)object\(fr) to the stream that is
  1799. the value of \(fp)*standard-output*\(ri '*standard-output*)\(fr).  The description of an object consists of several fields,
  1800. each of which is described in a recursive manner.  For example,
  1801. a symbol may have fields such as
  1802. home package, variable documentation, value, function documentation,
  1803. function binding, type documentation, \(fp)deftype\(ri 'deftype)\(fr) definition,
  1804. properties.
  1805. \(endd)
  1806.  
  1807. \(fp)inspect\(ri 'inspect) \(fi)object\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  1808. Prints the information about \(fi)object\(fr)
  1809. in an interactive manner.  The output of \(fp)inspect\(fr) is similar to that of \(fp)describe\(fr),
  1810. but after printing the label and the value of a field
  1811. (the value itself is not \(fp)describe\(fr)'d),
  1812. it prompts the user to input a one-character command.  The input to \(fp)inspect\(fr) is taken from the stream
  1813. that is the value of \(fp)*query-io*\(ri '*query-io*)\(fr).  Normally, the
  1814. inspection of \(fi)object\(fr) terminates
  1815. after all of its fields have been inspected.  The following commands are
  1816. supported:
  1817. \(br)
  1818. \(fp)n\(fr)    \(sm)Next.  Goes to the next level; the field is inspected recursively.\(rm)
  1819.  
  1820. \(fp)s\(fr)    \(sm)Skip.  Skips the inspection of the field. \(fp)inspect\(fr) proceeds to the next field.\(rm)
  1821.  
  1822. \(fp)p\(fr)    \(sm)Print.  Pretty-prints the field and prompts again.\(rm)
  1823.  
  1824. \(fp)u \(fi)form\(fr)    \(sm)Update.  The \(fi)form\(fr) is evaluated and the field is replaced by the resulted value.  If the field cannot be updated, the message \(fp)Not updated.\(fr) will be printed.\(rm)
  1825.  
  1826. \(fp)a\(fr)    \(sm)Abort.  Aborts the inspection of the current object.  The field and the rest of the fields are not inspected.\(rm)
  1827.  
  1828. \(fp)e \(fi)form\(fr)    \(sm)Eval.  Evaluates the specified form in the null environment and prints the resulted values.  Then prompts again with the same field.\(rm)
  1829.  
  1830. \(fp)q\(fr)    \(sm)Quit.  Aborts the entire inspection.\(rm)
  1831.  
  1832. \(fp)?\(fr)    \(sm)Help.  Lists the \(fp)inspect\(fr) commands.\(rm)
  1833. \(endd)
  1834.  
  1835. \(fg) 
  1836.  
  1837. \(ce)Chapter 6. The Compiler
  1838. \(set-page pp-6)
  1839. \(fr)
  1840. The KCL compiler translates a Lisp program stored
  1841. in a source file
  1842. into a C-language program, invokes the C-language compiler to compile
  1843. the C-language program, and then generates an object file, called
  1844. \(fi)fasl file\(fr) (or \(fi)o-file\(fr) because of the actual filetype).  The compiled program in a fasl file is loaded by
  1845. the function \(fp)load\(ri 'load)\(fr).
  1846.  
  1847.      Ordinarily, the object program generated by the KCL compiler scarcely
  1848. does runtime
  1849. error-checking for runtime efficiency.  In addition, Lisp functions in the
  1850. same source file are linked together and some system functions are
  1851. open-coded in-line.  To control runtime error checking, supply
  1852. appropriate \(fp)optimize\(fr) declarations (see Section 7.1).
  1853.  
  1854.      The KCL compiler processes
  1855. the \(fp)eval-when\(ri 'eval-when)\(fr) special form
  1856. exactly as specified in the \(fi)Common Lisp Reference
  1857. Manual\(fr).  However, all top-level forms in the source file are normally
  1858. processed in \(fi)compile-time-too\(fr) mode, not
  1859. in \(fi)not-compile-time\(fr) mode (see Section 5.3.3 of the
  1860. \(fi)Common Lisp Reference Manual\(fr)).  That is, each top-level form
  1861. \(fi)top-level-form\(fr) is processed as if it were surrounded by the
  1862. \(fp)eval-when\(fr) special form with the situations \(fp)compile\(fr),
  1863. \(fp)load\(fr), and \(fp)eval\(fr).
  1864. \(fp)
  1865.     (eval-when (compile load eval) \(fi)top-level-form\(fp))
  1866. \(fr)
  1867. There is no exception for this rule.  Thus, for instance, in the example of
  1868. \(fp)set-macro-character\(fr) form in Section 5.3.3 of the \(fi)Common Lisp
  1869. Reference Manual\(fr), the surrounding \(fp)eval-when\(fr) form is
  1870. unnecessary in KCL.  If it is desired that each top-level form be
  1871. processed in \(fi)not-compile-time\(fr) mode, change the
  1872. value of the KCL specific variable
  1873. \(fp)*eval-when-compile*\(ri '*eval-when-compile*)\(fr) as described below.
  1874.  
  1875.      The KCL compiler is invoked by the functions \(fp)compile-file\(fr),
  1876. \(fp)compile\(fr), and \(fp)disassemble\(fr) described below.  In addition,
  1877. the KCL compiler may
  1878. be invoked directly by the Shell
  1879. commands \(fp)lc\(fr) or
  1880. \(fp)lc1\(fr).  These commands require the file name of the source file as
  1881. their argument.  Both \(fp)lc\(fr) and \(fp)lc1\(fr) simply
  1882. adds \(fp)".lsp"\(fr) to the file name argument to obtain the full name of the
  1883. source file.
  1884. \(fp)
  1885.     % lc \(fi)filename
  1886. \(fr)
  1887. has the same effects as the compiler invocation \(fp)(compile-file "\(fi)filename\(fp)")\(fr) from within
  1888. KCL, and
  1889. \(fp)
  1890.     % lc1 \(fi)filename
  1891. \(fr)
  1892. has the same effects as \(fp)(compile-file "\(fi)filename\(fp)" :o-file t :c-file t :h-file t :data-file t)\(fr).
  1893.  
  1894.  
  1895. \(fp)compile-file\(ri 'compile-file) \(fi)input-pathname\(fp) \(fr)\(ra)[\(fi)Function\(fr)]
  1896.     \(fp)&key :output-file\(ri ':output-file) :o-file\(ri ':o-file) :c-file\(ri ':c-file) :h-file\(ri ':h-file) :data-file\(ri ':data-file)\(fr)\(bd)\(br)
  1897. \(fp)compile-file\(fr) compiles the Lisp program stored in the file
  1898. specified by \(fi)input-pathname\(fr), and generates a fasl file.  Also \(fp)compile-file\(fr) generates the following temporary files.
  1899. \(reserve 5)
  1900.     \(fi)Temporary File    Contents\(fr)
  1901.     \(fs)------------------------------------------------\(fr)
  1902.     \(fi)c-file\(fr)        C version of the Lisp program
  1903.     \(fi)h-file\(fr)        The include file referenced in the c-file
  1904.     \(fi)data-file\(fr)        The Lisp data to be used at load time
  1905.  
  1906. If files of these names already exist, the old files will be
  1907. deleted first.  Usually,
  1908. these intermediate files are automatically deleted after execution of
  1909. \(fp)compile-file\(fr).
  1910.  
  1911.      The input-file is determined in the usual
  1912. manner (see Section 2.9), except
  1913. that, if the filetype is not specified, then the default filetype
  1914. \(fp).lsp\(fr) will be used.  The keyword parameter \(fp):output-file\(fr)
  1915. defines the default directory and the default name to be applied to
  1916. the output files (i.e., the fasl file and
  1917. the temporary files).  \(fp):output-file\(fr) itself defaults
  1918. to \(fi)input-pathname\(fr).  That is, if \(fp):output-file\(fr) is not
  1919. supplied, then the
  1920. directory and the name of the input file will be used as the default
  1921. directory and the default name for the output files.  The filetypes
  1922. of the output files are fixed as follows.
  1923. \(reserve 6)
  1924.     \(fi)Output File    Filetype\(fr)
  1925.     \(fs)----------------------\(fr)
  1926.     fasl file        \(fp).o\(fr)
  1927.     c-file        \(fp).c\(fr)
  1928.     h-file        \(fp).h\(fr)
  1929.     data-file        \(fp).data\(fr)
  1930.  
  1931. Each output file can be specified by the corresponding keyword
  1932. parameter.  If the value of the keyword parameter is \(fp)nil\(fr), then
  1933. the output file will
  1934. be deleted after execution of \(fp)compile-file\(fr).  If the value of
  1935. the keyword
  1936. parameter is \(fp)t\(fr), then the output file will be left in the
  1937. default directory under the default name.  Otherwise,
  1938. the output file will be left in the directory under the name specified by
  1939. the keyword parameter.  The default value
  1940. of \(fp):o-file\(fr)
  1941. is \(fp)t\(fr), and the default values of
  1942. \(fp):c-file\(fr), \(fp):h-file\(fr),
  1943. and \(fp):data-file\(fr) are all \(fp)nil\(fr).
  1944.  
  1945.      Example:
  1946. \(reserve 3)
  1947.     \(fp)(compile-file 'foo)\(fr)
  1948.         The source file is \(fp)"FOO.lsp"\(fr) and the fasl file is \(fp)"FOO.o"\(fr)
  1949.         both in the current directory.
  1950. \(reserve 2)
  1951.     \(fp)(compile-file 'foo.lish)\(fr)
  1952.         The source file is \(fp)"FOO.LISH"\(fr) and the fasl file is \(fp)"FOO.o"\(fr).
  1953. \(reserve 3)
  1954.     \(fp)(compile-file "/usr/mas/foo" :output-file "/usr/tai/baa")\(fr)
  1955.         The source file is \(fp)"foo.lsp"\(fr) in the directory \(fp)"/usr/mas"\(fr),
  1956.         and the fasl file is \(fp)"baa.o"\(fr) in the directory \(fp)"/usr/tai"\(fr).
  1957.  
  1958. \(endd)
  1959. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  1960.  
  1961. The compiler of KCL/AOS generates the following output files.
  1962. \(reserve 6)
  1963.     \(fi)Output File    Filetype        Contents\(fr)
  1964.     \(fs)------------------------------------------------------------\(fr)
  1965.     fasl file        \(fp).fasl\(fr)    The fasl file
  1966.     c-file        \(fp).c\(fr)    C version of the Lisp program
  1967.     h-file        \(fp).h\(fr)    The include file referenced in the c-file
  1968.     ob-file        \(fp).ob\(fr)    The object file generated by the C compiler
  1969.     data-file        \(fp).data\(fr)    The Lisp data to be used at load time
  1970.  
  1971. Note that the filetype of the fasl file is \(fp).fasl\(fr) in KCL/AOS.  Also
  1972. note that the compiler of KCL/AOS generates
  1973. an additional file \(fi)ob-file\(fr).  Accordingly, the function
  1974. \(fp)compile-file\(fr) has a slightly different definition:
  1975.  
  1976. \(fp)compile-file\(ri 'compile-file) \(fi)input-pathname\(fp) \(fr)\(ra)[\(fi)Function\(fr)]
  1977.     \(fp)&key :output-file\(ri ':output-file) :fasl-file\(ri ':fasl-file) :c-file\(ri ':c-file) :h-file\(ri ':h-file) :ob-file\(ri ':ob-file) :data-file\(ri ':data-file)\(fr)
  1978.  
  1979. The keyword parameter \(fp):fasl-file\(fr) corresponds to the keyword
  1980. parameter \(fp):o-file\(fr) in KCL on Unix.  In particular, the default
  1981. value of \(fp):fasl-file\(fr) is \(fp)t\(fr) and the default values of
  1982. \(fp):c-file\(fr), \(fp):h-file\(fr), \(fp):ob-file\(fr), and
  1983. \(fp):data-file\(fr) are all \(fp)nil\(fr).  In KCL/AOS,
  1984. \(fp)
  1985.     ) lc1 \(fi)filename\(fr)
  1986.  
  1987. has the same effects as \(fp)(compile-file "\(fi)filename\(fp)" :fasl-file t :c-file t :h-file t :ob-file t :data-file t)\(fr).
  1988.  
  1989.      Because KCL/AOS follows the convention of the AOS/VS file system, the
  1990. last example above should be replaced as:
  1991. \(reserve 3)
  1992.     \(fp)(compile-file ":udd:mas:foo" :output-file ":udd:tai:baa")\(fr)
  1993.         The source file is \(fp)"FOO.LSP"\(fr) in the directory \(fp)":UDD:MAS"\(fr),
  1994.         and the fasl file is \(fp)"BAA.FASL"\(fr) in the directory \(fp)":UDD:TAI"\(fr).
  1995.  
  1996. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  1997.  
  1998.  
  1999. \(fp)compile\(ri 'compile) \(fi)name\(fp) &optional \(fi)definition\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2000. If \(fi)definition\(fr) is not supplied, \(fi)name\(fr) should be the name
  2001. of a not-yet-compiled function.  In this case,\(fp) compile\(fr) compiles the
  2002. function, replaces the previous definition of \(fi)name\(fr)
  2003. with the compiled function, and returns
  2004. \(fi)name\(fr).  If\(fi) definition\(fr) is supplied, it should be a
  2005. lambda-expression to be compiled and \(fi)name\(fr) should
  2006. be a symbol.  If \(fi)name\(fr) is a non-\(fp)nil\(fr) symbol,
  2007. then \(fp)compile\(fr) installs the compiled function as the function
  2008. definition
  2009. of \(fi)name\(fr) and returns \(fi)name\(fr).  If\(fi) name\(fr)
  2010. is \(fp)nil\(fr), then \(fp)compile\(fr) simply returns the
  2011. compiled function.
  2012.  
  2013.      The KCL compiler is essentially a file compiler, and forms to be compiled
  2014. are supposed to be stored in a file.  Thus \(fp)compile\(fr) actually
  2015. creates a source file which
  2016. contains the form designated by the arguments.  Then \(fp)compile\(fr)
  2017. calls \(fp)compile-file\(ri 'compile-file)\(fr) to get a fasl file, which
  2018. is then loaded into KCL.  The source file and the fasl file are given the
  2019. names \(fp)gazonk.lsp\(fr) and \(fp)gazonk.fasl\(fr), respectively.  These files are not
  2020. deleted automatically after the execution of \(fp)compile\(fr).
  2021. \(endd)
  2022.  
  2023. \(fp)disassemble\(ri 'disassemble) \(fp)&optional \(fi)thing\(fp) &key :h-file :data-file\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2024. This function does not actually disassemble.  It always
  2025. calls the KCL compiler and
  2026. prints the contents of the c-file, i.e., the C-language code, generated by
  2027. the KCL compiler.  If \(fi)thing\(fr) is not supplied, or if it is \(fp)nil\(fr), then
  2028. the previously compiled form by \(fp)disassemble\(fr) will be
  2029. compiled again.  If \(fi)thing\(fr) is a symbol other than \(fp)nil\(fr),
  2030. then it must be the
  2031. name of a not-yet-compiled
  2032. function, whose definition is to be compiled.  In this case, it is an error if
  2033. the name is associated with a special form or a macro.  If \(fi)thing\(fr)
  2034. is a lambda-expression
  2035. \(fp)(lambda \(fi)lambda-list \(fp). \(fi)body\(fp))\(fr), then
  2036. \(fp)disassemble\(fr) first creates a function definition \(fp)(defun gazonk \(fi)lambda-list\(fp) . \(fi)body\(fp))\(fr) and this definition
  2037. is compiled.  (The function name \(fp)gazonk\(fr) has
  2038. no special meanings.  Indeed,
  2039. the displayed code is essentially independent
  2040. of the function name.)  Otherwise, \(fi)thing\(fr) itself
  2041. will be compiled as a top-level form.  In any case, \(fp)disassemble\(fr)
  2042. does not install the compiled
  2043. function.  \(fp)disassemble\(fr) returns no value.
  2044.  
  2045.     No intermediate h-file is created if the keyword parameter
  2046. \(fp):h-file\(fr) is \(fp)nil\(fr) or if \(fp):h-file\(fr) is not
  2047. supplied.  Otherwise, an intermediate h-file is created under the name
  2048. specified by \(fp):h-file\(fr).  Similarly, the intermediate data-file
  2049. is specified by the keyword parameter \(fp):data-file\(fr).
  2050. \(endd)
  2051.  
  2052. \(fp)*eval-when-compile*\(ri '*eval-when-compile*)\(fr)\(ra)[\(fi)Variable\(fr)]\(bd)
  2053. The compiler processes each top-level form
  2054. in \(fi)not-compile-time\(fr) mode if the value of this
  2055. variable is \(fp)nil\(fr), and in \(fi)compile-time-too\(fr) mode,
  2056. otherwise.  See Section 5.3.3 of \(fi)Common Lisp Reference Manual\(fr)
  2057. for these two modes.  The initial value of this variable is \(fp)t\(fr).
  2058. \(endd)
  2059.  
  2060.  
  2061. \(fg) 
  2062.  
  2063. \(ce)Chapter 7. Declarations
  2064. \(set-page pp-7)
  2065. \(fr)
  2066. KCL supports all kinds of declarations described in the
  2067. \(fi)Common Lisp Reference Manual\(fr).  Any valid declaration
  2068. will affect the KCL environment in some way or another, although information
  2069. obtained by declarations, other than \(fp)special\(fr) declarations,
  2070. is mainly used by the KCL compiler.
  2071.  
  2072.      As described in the \(fi)Common Lisp Reference Manual\(fr),
  2073. Common Lisp declarations are divided into two classes: \(fi)proclamations\(fr)
  2074. and others.  A proclamation is a global declaration given by the function
  2075. \(fp)proclaim\(ri 'proclaim)\(fr), the top-level
  2076. macro \(fp)defvar\(ri 'defvar)\(fr), or the top-level
  2077. macro \(fp)defparameter\(ri 'defparameter)\(fr).  Once given,
  2078. a proclamation remains effective
  2079. during the KCL session unless it is shadowed by a local declaration or is
  2080. canceled by another proclamation.  Any other declaration is a \(fi)local
  2081. declaration\(fr) and is given only by the special
  2082. form \(fp)declare\(ri 'declare)\(fr).  A local declaration remains in
  2083. effect only within the body of the construct that surrounds the
  2084. declaration.  In the following nonsensical example borrowed from
  2085. Chapter 9 of the \(fi)Common Lisp Reference Manual\(fr),
  2086. \(reserve 6)\(fp)
  2087.     (defun nonsense (k x z)
  2088.       (foo z x)
  2089.       (let ((j (foo k x))
  2090.             (x (* k k)))
  2091.            (declare (inline foo) (special x z))
  2092.         (foo x j z)))
  2093. \(fr)
  2094. the \(fp)inline\(fr) and the \(fp)special\(fr) declarations both remain
  2095. in effect within the surrounding \(fp)let\(fr) form.  In this case,
  2096. we say that the \(fp)let\(fr) form is the \(fi)surrounding
  2097. construct\(fr) of these declarations.
  2098.  
  2099. \(fp)proclamation\(ri 'proclamation) \(fi)decl-spec\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2100. This function is introduced to KCL so that the user can see currently
  2101. effective proclamations.  The argument \(fi)decl-spec\(fr) specifies the
  2102. proclamation to be checked.  It may be any declaration specification that
  2103. can be a valid argument to the function \(fp)proclaim\(fr).  The
  2104. function \(fp)proclamation\(fr) returns \(fp)t\(fr) if the specified
  2105. proclamation is still in effect.  Otherwise, it returns \(fp)nil\(fr).
  2106. For example,
  2107. \(reserve 2)\(fp)
  2108.     >(proclaim '(special *x*))  ;;; \(fr)The variable \(fp)*x*\(fr) is\(fp)
  2109.     nil                         ;;; \(fr)proclaimed to be globally special.\(fp)
  2110. \(reserve 2)
  2111.     >(proclamation '(special *x*))
  2112.     t
  2113. \(reserve 2)
  2114.     >(defvar *y*)               ;;; \(fr)Another way to proclaim a variable\(fp)
  2115.     nil                         ;;; \(fr)to be globally special.\(fp)
  2116. \(reserve 2)
  2117.     >(proclamation '(special *y*))
  2118.     t
  2119. \(fr)
  2120. \(endd)
  2121. \(fp)the\(ri 'the) \(fi)value-type\(fr) \(fi)form\(fr)\(ra)[\(fi)Special Form\(fr)]\(bd)
  2122. The KCL interpreter does actually check whether the value of the
  2123. \(fi)form\(fr) conforms to the data type specified by \(fi)value-type\(fr) and
  2124. signals an error if the value does not.  The type checking is performed by
  2125. the function \(fp)typep\(ri 'typep)\(fr).  For example,
  2126. \(fp)
  2127.     (the fixnum (foo))
  2128. \(fr)
  2129. is equivalent to
  2130. \(reserve 7)\(fp)
  2131.  (let ((values (multiple-value-list (foo))))
  2132.    (cond ((endp values) (error "Too few return values."))
  2133.          ((not (endp (cdr values)))
  2134.           (error "Too many return values."))
  2135.          ((typep (car values) 'fixnum) (car values))
  2136.          (t (error "~s is not of type fixnum." (car values)))))
  2137. \(fr)
  2138. On the other hand, the KCL compiler uses the \(fp)the\(fr) special form to
  2139. obtain type information for compiled code optimization.  No code for runtime
  2140. type-checking is embedded in the compiled code.
  2141. \(endd)
  2142. \(reserve 5)\(fg)
  2143. 7.1. Declaration Specifiers\(set-page pp-7-1)
  2144. \(fr)
  2145. KCL recognizes all declaration specifiers defined in the
  2146. \(fi)Common Lisp Reference Manual\(fr).  The syntax of each such declaration
  2147. specifier is exactly the same as defined
  2148. in the \(fi)Common Lisp Reference Manual\(fr).  In addition, KCL recognizes the
  2149. \(fp)object\(ri 'object)\(fr) declaration specifier which is specific to KCL.
  2150.  
  2151. \(fp)special\(ri 'special)\(fr) { \(fi)variable-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2152. The interpreter and the compiler of KCL both treat \(fp)special\(fr)
  2153. declarations exactly as described in the \(fi)Common Lisp Reference Manual\(fr).
  2154. \(endd)
  2155.  
  2156. \(fp)type\(ri 'type) \(fi)type\(fr) { \(fi)variable-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2157. A \(fp)type\(fr) proclamation \(fp)(type \(fi)type var1
  2158. var2\(fr) ...\(fp))\(fr) specifies that the dynamic values of the
  2159. named variables are of the type \(fi)type\(fr).  A local \(fp)type\(fr)
  2160. declaration specifies that the variables mentioned are bound by the
  2161. surrounding construct and have values of the type \(fi)type\(fr) during
  2162. execution of the surrounding construct.  The compiler issues a warning if
  2163. one of the named variables is not bound by
  2164. the surrounding construct.  The information given by
  2165. \(fp)type\(fr) declarations is used by the compiler to optimize
  2166. the compiled code.  The behavior of the compiled code
  2167. is unpredictable if a wrong \(fp)type\(fr) declaration is supplied.  The
  2168. compiler detects certain wrong \(fp)type\(fr) declarations at compile
  2169. time.  For example,
  2170. \(reserve 5)\(fp)
  2171.     >(defun foo (x y)
  2172.        (declare (fixnum x) (character y))
  2173.        (setq x y)
  2174.       ...))
  2175.     foo
  2176. \(reserve 4)
  2177.     >(compile 'foo)
  2178.  
  2179.     ; (defun foo ...) is being compiled.
  2180.     ;; Warning: Type mismatches between x and y.\(fr)
  2181.  
  2182. See Section 7.3 for further information on \(fp)type\(fr) declarations.
  2183. \(endd)
  2184.  
  2185. \(fi)type\(fr) { \(fi)variable-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2186. \(fp)(\(fi)type var1 var2\(fr) ...\(fp))\(fr) is equivalent to
  2187. \(fp)(type \(fi)type var1 var2\(fr) ...\(fp))\(fr), provided
  2188. that \(fi)type\(fr) is one of the symbols in Table 4-1
  2189. of the \(fi)Common Lisp Reference Manual\(fr), other
  2190. than \(fp)function\(fr).  Declaration specification that begins
  2191. with \(fp)function\(fr) are
  2192. regarded as \(fp)function\(fr) declarations (see below).
  2193. \(endd)
  2194.  
  2195. \(fp)function\(ri 'function) \(fi)function-name argument-types\(fr) . \(fi)return-types\(fr)\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2196. A \(fp)function\(fr) declaration is used to obtain type
  2197. information for function call forms.
  2198. That is, a \(fp)function\(fr) declaration specifies
  2199. the argument and the return types
  2200. types of each form that calls the named function.
  2201. \(reserve 3)\(fp)
  2202.     (defun foo ()
  2203.       (declare (function bar (character) fixnum))
  2204.       (+ (bar (atcholi1)) (bar (atcholi2))))
  2205. \(fr)
  2206. In this example, the \(fp)function\(fr) declaration
  2207. specifies that
  2208. the two functions \(fp)atcholi1\(fr) and \(fp)atcholi2\(fr) both return
  2209. character objects when called
  2210. within the body of \(fp)foo\(fr), and that the function \(fp)bar\(fr)
  2211. returns fixnum objects when called within the body of \(fp)foo\(fr).
  2212. The type information given by
  2213. \(fp)function\(fr) declarations is used by the compiler to optimize
  2214. the compiled code.  The behavior of the compiled code
  2215. is unpredictable if a wrong \(fp)function\(fr) declaration is supplied.
  2216. The compiler detects certain wrong \(fp)function\(fr) declarations at compile
  2217. time.  For example,
  2218. \(reserve 5)\(fp)
  2219.     >(defun foo (x)
  2220.        (declare (fixnum x)
  2221.                 (function bar (character) fixnum))
  2222.        (bar x))
  2223.     foo
  2224. \(reserve 4)
  2225.     >(compile 'foo)
  2226.  
  2227.     ; (defun foo ...) is being compiled.
  2228.     ;; Warning: The type of the form x is not character.
  2229. \(fr)
  2230. However, the compiler does not check the number of arguments, and thus,
  2231. the following function definition will be compiled successfully without
  2232. any warnings.
  2233. \(reserve 3)\(fp)
  2234.     (defun foo ()
  2235.       (declare (function bar (character character) fixnum))
  2236.       (+ (bar (atcholi1)) (bar (atcholi2) (atcholi3) (atcholi4))))
  2237. \(fr)
  2238. For this definition, the compiler assumes that the three functions
  2239. \(fp)atcholi1\(fr), \(fp)atcholi2\(fr), and \(fp)atcholi3\(fr) will
  2240. return fixnum objects.  The return type of \(fp)atcholi4\(fr) is
  2241. unknown at compile time.
  2242.  
  2243. The complete syntax of a \(fp)function\(fr) declaration is:
  2244. \(reserve 4)\(fp)
  2245.     (function \(fi)function-name\(fp)
  2246.       ( \(fr){\(fp) \(fi)type\(fp) \(fr)}*\(fp) \(fr)[\(fp) \(fr){\(fp) &optional \(fr)|\(fp) &rest \(fr)|\(fp) &key \(fr)}\(fp) \(fr){\(fp) \(fi)thing\(fp) \(fr)}*\(fp) \(fr)]\(fp) )
  2247.       \(fr){\(fp) (values \(fr){\(fp) \(fi)type\(fp) \(fr)}* \(fp)) \(fr)|\(fp) \(fr){\(fp) \(fi)type\(fp) \(fr)}*\(fp) \(fr)}\(fp)
  2248.      )
  2249. \(fr)
  2250. Although \(fp)&optional\(fr), \(fp)&rest\(fr), and \(fp)&key\(fr) markers
  2251. may appear in the list of argument types, only those \(fi)type\(fr)s are
  2252. recognized that appear before any such markers and the rest of the
  2253. list is simply ignored.  Note that
  2254. functions with \(fp)&optional\(fr), \(fp)&rest\(fr), or \(fp)&key\(fr)
  2255. parameters may still be declared by \(fp)function\(fr) declarations because
  2256. of the use of \(fp)function\(fr) declarations mentioned above.
  2257.  
  2258. The \(fp)values\(fr) construct in the specification of return types is almost
  2259. useless:  \(fp)(function \(fi)function-name argument-types\(fp)
  2260. (values \(fi)type1 type2 \(fr)...\(fp)))\(fr) is equivalent
  2261. to \(fp)(function \(fi)function-name
  2262. argment-types \(fi)type1 type2 \(fr)...\(fp))\(fr).  We, the implementors of
  2263. KCL wonder why the \(fp)value\(fr) construct was introduced in Common Lisp.
  2264.  
  2265. See Section 7.3 for further information on \(fp)function\(fr) declarations.
  2266. \(endd)
  2267.  
  2268. \(fp)ftype\(ri 'ftype) \(fi)function-type\(fr) { \(fi)function-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2269. \(fi)function-type\(fr) must be a list whose first element
  2270. is the symbol \(fp)function\(fr).
  2271. \(fp)(ftype (function \(fr). \(fi)rest\(fp)) \(fi)function-name-1\(fr) ... \(fi)function-name-n\(fp))\(fr) is
  2272. equivalent to \(fi)n\(fr) consecutive \(fp)function\(fr) declarations
  2273. \(fp)(function \(fi)function-name-1\(fr) . \(fi)rest\(fp))\(fr) ...
  2274. \(fp)(function \(fi)function-name-n\(fr) . \(fi)rest\(fp))\(fr).
  2275. \(endd)
  2276.  
  2277. \(fp)notinline\(ri 'notinline) \(fr){ \(fi)function-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2278. \(fp)(notinline \(fi)function1 function2\(fr) ...\(fp))\(fr) specifies
  2279. that the compiler should not compile the named functions in-line.  Calls
  2280. to the named functions can be traced and an event (see Section 5.4) is pushed
  2281. on the event stack when any one of the named functions is invoked.
  2282. \(endd)
  2283.  
  2284. \(fp)inline\(ri 'inline) \(fr){ \(fi)function-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2285. An \(fp)inline\(fr) proclamation cancels currently
  2286. effective \(fp)notinline\(fr) proclamations, and a local
  2287. \(fp)inline\(fr) declaration locally shadows currently effective
  2288. \(fp)notinline\(fr) declarations.
  2289. \(reserve 4)\(fp)
  2290.     >(defun foo (x)
  2291.        (cons (car x)
  2292.              (locally (declare (inline car)) (car x))))
  2293.     foo
  2294. \(reserve 4)
  2295.     >(defun bar (x)
  2296.        (cons (car x)
  2297.              (locally (declare (inline car)) (car x))))
  2298.     foo
  2299. \(reserve 2)
  2300.     >(proclaim '(notinline car))
  2301.     nil
  2302. \(reserve 2)
  2303.     >(compile 'foo)
  2304.     ...
  2305. \(reserve 2)
  2306.     >(proclaim '(inline car))
  2307.     nil
  2308. \(reserve 2)
  2309.     >(compile 'bar)
  2310.     ...
  2311. \(fr)
  2312. Usually, primitive functions such as \(fp)car\(fr) are
  2313. compiled in-line.  Therefore, in this example, only the first
  2314. call to \(fp)car\(fr) within \(fp)foo\(fr) is compiled not in-line,
  2315.  
  2316. In general, the KCL compiler compiles functions in-line
  2317. whenever possible.  Thus an \(fp)inline\(fr)
  2318. declaration \(fp)(inline \(fi)function1
  2319. function2\(fr) ...\(fp))\(fr) is worthless if none of the named functions
  2320. have previously been declared to be \(fp)notinline\(fr).
  2321. \(endd)
  2322.  
  2323. \(fp)ignore\(ri 'ignore) \(fr){ \(fi)variable-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2324. Usually, the compiler issues a warning if a lexical variable is
  2325. never referred to.  \(fp)(ignore \(fi)var1\(fr) ... \(fi)varn\(fp))\(fr)
  2326. causes the compiler not to issue a warning even if the named variables are
  2327. never referred to.  The compiler issues a warning if
  2328. one of the named variables is not bound by
  2329. the surrounding construct, or if a named variable is
  2330. actually referred to.  \(fp)ignore\(fr) proclamations are simply ignored.
  2331. \(endd)
  2332.  
  2333. \(fp)optimize\(ri 'optimize) \(fr){ {\(fp) (\(fi)quality value\(fp)) \(fr)| \(fi)quality \(fr)} }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2334. KCL supports the four \(fp)optimize\(fr) qualities listed in the
  2335. \(fi)Common Lisp Reference Manual\(fr).  \(fp)speed\(ri 'speed)\(fr)
  2336. and \(fp)compilation-speed\(ri 'compilation-speed)\(fr) are used to set up the optimization switch
  2337. of the C language compiler which is invoked to compile the C-language
  2338. code generated by the KCL compiler (see Chapter 6).  \(fp)(optimize (speed \(fi)n\(fp)))\(fr) and
  2339. \(fp)(optimize (compilation-speed \(fi)m\(fp)))\(fr) are equivalent,
  2340. where \(fi)n\(fr) and \(fi)m\(fr) are integers between \(fp)0\(fr)
  2341. and \(fp)3\(fr), and \(fi)m\(fr) is equal to \(fp)3-\(fi)n\(fr).  When
  2342. a KCL session is started, the \(fp)speed\(fr) quality is set
  2343. to \(fp)3\(fr).  That is, by default, the compiler generates the fastest
  2344. code in the longest compilation time.  The \(fp)space\(ri 'space)\(fr) quality
  2345. specifies whether the code size is important or not:  The compiled code
  2346. is a little bit larger and faster when compiled with the \(fp)space\(fr)
  2347. quality \(fp)0\(fr), than when compiled with the \(fp)space\(fr) quality
  2348. \(fp)1\(fr), \(fp)2\(fr), or \(fp)3\(fr).  When a KCL session is started,
  2349. the \(fp)space\(fr) quality is set to \(fp)0\(fr).  The \(fp)safety\(ri 'safety)\(fr)
  2350. quality determines how much runtime error checking code should be embedded in
  2351. the compiled code.  If the \(fp)safety\(fr) quality is \(fp)0\(fr), the
  2352. compiled code
  2353. scarcely does runtime error checking.  If
  2354. the \(fp)safety\(fr) quality is \(fp)1\(fr), then the compiled code for a
  2355. function will check the number of arguments to the function
  2356. at runtime.  If the \(fp)safety\(fr) quality is \(fp)2\(fr) or \(fp)3\(fr), then the
  2357. compiled code does full runtime error checking.  In addition, the
  2358. highest quality value \(fp)3\(fr) causes the compiler to treat all
  2359. functions as if they were declared to be \(fp)notinline\(fr).  When a KCL
  2360. session is started, the \(fp)safety\(fr) quality is set to
  2361. \(fp)0\(fr).
  2362. \(endd)
  2363.  
  2364. \(fp)declaration\(ri 'declaration) \(fr){ \(fi)name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2365. A \(fp)declaration\(fr) declaration is used exactly as specified in the
  2366. \(fi)Common Lisp Reference Manual\(fr).
  2367. \(endd)
  2368.  
  2369. \(fp)object\(ri 'object) \(fr){ \(fi)variable-name\(fr) }*\(ra)[\(fi)Declaration Specifier\(fr)]\(bd)
  2370. This is the only declaration specifier that is specific to KCL.  \(fp)(object
  2371. \(fi)var1\(fr) ... \(fi)varn\(fp))\(fr) affects only variable bindings and
  2372. specifies that the named variables can be allocated in the
  2373. C stack (see Section 7.3).  The compiler issues a warning if
  2374. one of the named variables is not bound by the surrounding
  2375. construct.  \(fp)object\(fr) proclamations are simply ignored.
  2376. \(endd)
  2377. \(reserve 5)\(fg)
  2378. 7.2. Significant Type Specifiers\(set-page pp-7-2)
  2379. \(fr)
  2380. Whenever a declaration is encountered, each type specifier (if any) in
  2381. the declaration is converted to one of the following type specifiers, which
  2382. are collectively called the \(fi)significant type specifiers\(fr).
  2383. \(reserve 19)\(fp)
  2384.           \(fs)1------------\(fp)  fixnum\(fs) 
  2385.           |
  2386.           \(fs)4------------\(fp)  character\(fs) 
  2387.           |
  2388.           \(fs)4------------\(fp)  short-float\(fs) 
  2389.           |
  2390.           \(fs)4------------\(fp)  long-float\(fs) 
  2391.           |
  2392.      \(fp)t  \(fs)--5--\(fp)  (array t)  \(fs)------------\(fp)  (vector t)\(fs) 
  2393.           |
  2394.           \(fs)4--\(fp)  (array fixnum)  \(fs)-------\(fp)  (vector fixnum)\(fs) 
  2395.           |
  2396.           \(fs)4--\(fp)  (array string-char)  \(fs)--\(fp)  string\(fs) 
  2397.           |
  2398.           \(fs)4--\(fp)  (array short-float)  \(fs)--\(fp)  (vector short-float)\(fs) 
  2399.           |
  2400.           \(fs)4--\(fp)  (array long-float)  \(fs)---\(fp)  (vector long-float)\(fs) 
  2401.           |
  2402.           \(fs)7--\(fp)  (array bit)  \(fs)----------\(fp)  bit-vector\(fs) 
  2403. \(fr)
  2404. Here, the lines indicate subtype relations; the right type
  2405. is a subtype of the left type.  For instance, \(fp)(vector t)\(fr)
  2406. is a subtype of \(fp)(array t)\(fr) and \(fp)t\(fr), and
  2407. \(fp)(array t)\(fr) itself is a subtype of \(fp)t\(fr).  However,
  2408. \(fp)(array t)\(fr) and \(fp)(array string-char)\(fr) are disjoint types.
  2409.  
  2410.      The function \(fp)subtypep\(fr) is used for the conversion to
  2411. significant type specifiers:  If the
  2412. first value of \(fp)(subtypep \(fi)raw-type type\(fp))\(fr) is
  2413. \(fp)t\(fr) for one of the significant type specifiers \(fi)type\(fr),
  2414. then the type specifier \(fi)raw-type\(fr) in
  2415. the declaration is converted to \(fi)type\(fr).  If there are more than one
  2416. such significant type specifiers, then the type specifier that is a
  2417. subtype of other specifiers is selected.  For
  2418. example, type specifiers \(fp)fixnum\(fr), \(fp)(mod 3)\(fr), and
  2419. \(fp)(member 0 1)\(fr) are all converted to \(fp)fixnum\(fr), though they are
  2420. also subtypes of \(fp)t\(fr).
  2421.  
  2422.      Because of this type specifier conversion, KCL may sometimes regard
  2423. two seemingly distinct declarations as the same.  For example,
  2424. the following \(fp)type\(ri 'type)\(fr) declarations are
  2425. completely equivalent, internally in KCL.
  2426. \(fp)
  2427.     (declare (type fixnum x))
  2428.  
  2429.     (declare (type (mod 3) x))
  2430.  
  2431.     (declare (type (member 0 1) x))
  2432. \(fr)
  2433. Type specifiers in declaration specifications passed to the
  2434. KCL specific function
  2435. \(fp)proclamation\(fr) are also converted to significant type specifiers.  Thus, for example,
  2436. \(reserve 2)\(fp)
  2437.     >(proclaim '(function foo (fixnum) fixnum))
  2438.     nil
  2439. \(reserve 2)
  2440.     >(proclamation '(function foo ((mod 3)) (member 0 1)))
  2441.     t
  2442. \(reserve 2)
  2443.     >(proclamation '(function foo (number) character))
  2444.     nil
  2445. \(fr)
  2446. The first call to \(fp)proclamation\(fr) returns \(fp)t\(fr) because
  2447. both \(fp)(mod 3)\(fr) and \(fp)(member 0 1)\(fr) are converted to
  2448. \(fp)fixnum\(fr) before the function type of \(fp)foo\(fr) is checked.
  2449.  
  2450. \(reserve 5)\(fg)
  2451. 7.3. Treatment of Type Declarations\(set-page pp-7-3)
  2452. \(fr)
  2453. KCL has several runtime stacks.  One of them is called the \(fi)value
  2454. stack\(fr) which is the "main stack" of KCL:  Arguments to functions and
  2455. resulted values of functions are usually passed via the value stack,
  2456. lexical variables in compiled code are usually allocated on the value stack,
  2457. and temporary values during evaluation of nested expressions are usually
  2458. saved on the value stack.  However, if appropriate declarations are
  2459. supplied to the compiler, the compiled code will use another
  2460. stack called the \(fi)C stack\(fr), which can be accessed more efficiently
  2461. than the value stack.  In addition, arguments and resulted values passed
  2462. via the C stack, values of lexical variables allocated on the C stack,
  2463. and temporary values saved on the C stack may sometimes be represented
  2464. as \(fi)raw data\(fr) instead of pointers to heap-allocated
  2465. cells.  In KCL, even a fixnum object is usually represented as a pointer
  2466. to a fixnum cell in which the raw datum (i.e., the 32-bit signed integer)
  2467. for the fixnum is stored.  Accessing such raw data on the C stack results
  2468. in faster compiled code,
  2469. partly because no pointer deferencing operation is necessary, and
  2470. partly because no cell is newly allocated on the heap when a new object is
  2471. created.  In contrast, any object on the value stack is represented
  2472. as a pointer to a heap-allocated cell.
  2473.  
  2474.      One of the deficiencies of the use of the C stack is that
  2475. raw data on the C stack may sometimes need to be reallocated on the
  2476. heap.  Suppose, in the following example, that
  2477. the lexical variable \(fp)x\(fr) is
  2478. allocated on the C stack and has always a fixnum raw datum as its
  2479. value.  (The situations in which this occurs will be explained later.)
  2480. \(reserve 6)\(fp)
  2481.     (defun foo ()
  2482.       (let ((x 0))
  2483.         ....
  2484.         (bar x)
  2485.         ....
  2486.         ))
  2487. \(fr)
  2488. Also suppose that the function \(fp)bar\(fr) expects its argument to be
  2489. passed via the value stack rather than via the C stack.  (This situation
  2490. typically occurs when \(fp)foo\(fr) and \(fp)bar\(fr) are defined in separate
  2491. source files.  See below.)  On call to \(fp)bar\(fr), the compiled code
  2492. of \(fp)foo\(fr) will allocate a fixnum cell on the heap and push the pointer
  2493. to this cell on the value stack as the argument to \(fp)bar\(fr).
  2494.  
  2495.      Another deficiency is that it is sometimes dangerous to allocate
  2496. a cell pointer onto the C stack.  (This occurs when
  2497. \(fp)object\(ri 'object)\(fr) declarations
  2498. are supplied.  See below.)  The garbage
  2499. collector of KCL never takes care of cell pointers on the C stack and thus
  2500. a heap-allocated cell pointed
  2501. to only from the C stack may be recycled for
  2502. further use, while the data in the cell is still in use.  This is why
  2503. KCL usually uses the less efficient value
  2504. stack.  In contrast, objects on the value stack are automatically
  2505. protected against
  2506. garbage collection.  Note that raw data on the C stack need not be protected
  2507. against garbage collection because they remain alive until the C stack is
  2508. poped.
  2509.  
  2510. \(reserve 5)\(fg)
  2511. 7.3.1. Variable Allocations\(set-page pp-7-3-1)
  2512. \(fr)
  2513. If a lexical variable is declared to be of \(fp)fixnum\(fr),
  2514. \(fp)character\(fr), \(fp)short-float\(fr), \(fp)long-float\(fr), or
  2515. their subtypes, then it is allocated on the C stack rather than on the
  2516. value stack.  In addition, the variable always has a raw datum as its
  2517. value: 32 bit signed integer for fixnums, 8 bit character code
  2518. with 24 bit padding for
  2519. characters (remember that the font and bit fields of KCL characters are
  2520. always \(fp)0\(fr)), 32 bit floating point representation for short-floats,
  2521. and 64 bit floating point representation for
  2522. long-floats.  Similarly, if a lexical variable is named in an \(fp)object\(ri 'object)\(fr) declaration (see Section 7.1),
  2523. then it is allocated on the C stack but, in this case, the variable
  2524. always has a cell pointer as its value.  The user is strongly recommended to
  2525. make sure that objects stored in such an \(fp)object\(fr) variable may
  2526. never be garbage collected unexpectedly.  For example,
  2527. \(reserve 5)\(fp)
  2528.     (do ((x (foo) (cdr x)))
  2529.         ((endp x))
  2530.         (let ((y (car x)))
  2531.              (declare (object y))
  2532.           (bar y)))
  2533. \(fr)
  2534. this \(fp)object\(fr) declaration is completely safe because the value of
  2535. the variable \(fp)y\(fr) is always a substructure of the value
  2536. of \(fp)x\(fr), which in turn is protected against garbage
  2537. collection.  Incidentally, loop variables of \(fp)dolist\(fr) may always be
  2538. declared as \(fp)object\(fr) variables, since the \(fp)dolist\(fr) form has
  2539. essentially the same control structure as the \(fp)do\(fr) form above.  On
  2540. the other hand, the result of evaluation of the following form is
  2541. unpredictable, because the cons cell pointed to from the \(fp)object\(fr)
  2542. variable \(fp)z\(fr) may be garbage collected before \(fp)bar\(fr) is called.
  2543. \(reserve 4)\(fp)
  2544.     (let ((z (cons x y)))
  2545.          (declare (object z))
  2546.       (foo (cons x y))
  2547.       (bar z))
  2548. \(fr)
  2549.      Lexical variables that are not declared to be of \(fp)fixnum\(fr),
  2550. \(fp)character\(fr), \(fp)short-float\(fr), \(fp)long-float\(fr), or
  2551. their subtypes, and that are not named in \(fp)object\(fr) declarations are
  2552. usually allocated on the value stack, but may possibly
  2553. be allocated on the C stack automatically by the compiler.
  2554.  
  2555. \(reserve 5)\(fg)
  2556. 7.3.2. Built-in Functions that Operate on Raw Data Directly \(set-page pp-7-3-2)
  2557. \(fr)
  2558. Some built-in Common Lisp functions can directly operate on raw data, if
  2559. appropriate declarations are supplied.  The addition function \(fp)+\(fr) is
  2560. among such functions.
  2561. \(reserve 6)\(fp)
  2562.     (let ((x 1))
  2563.          (declare (fixnum x))
  2564.       ....
  2565.       (setq x (+ x 2))
  2566.       ....
  2567.       )
  2568. \(fr)
  2569. In the compiled code for this \(fp)let\(fr) form, the raw fixnum datum (i.e.,
  2570. the 32 bit signed integer) stored
  2571. in \(fp)x\(fr) is simply incremented by 2 and the resulted 32 bit signed
  2572. integer is stored back into \(fp)x\(fr).  The compiler is sure that
  2573. the addition for 32 bit signed integers
  2574. will be performed on the call to \(fp)+\(fr), because
  2575. the arguments are both fixnums
  2576. and the return value must be also a fixnum since the value
  2577. is to be assigned to the \(fp)fixnum\(fr) variable.  The knowledge
  2578. of both the argument types and the return type is necessary
  2579. for this decision:  Addition of two fixnums
  2580. may possibly produce a bignum and addition of two bignums may happen to
  2581. produce a fixnum value.  If either the argument type or the return type
  2582. were not known to the
  2583. compiler, the general addition function would be called to
  2584. handle the general case.  In the following form, for example, 
  2585. the compiler cannot be sure that the return value of the multiplication is
  2586. a fixnum or that the arguments of the addition are fixnums.
  2587. \(fp)
  2588.     (setq x (+ (* x 3) 2))
  2589. \(fr)
  2590. In order to obtain the optimal code,
  2591. a \(fp)the\(ri 'the)\(fr) special form should surround the multiplication.
  2592. \(fp)
  2593.     (setq x (+ (the fixnum (* x 3)) 2))
  2594. \(fr)
  2595.  
  2596.      Built-in Common Lisp functions that can directly operate on raw data are:
  2597.  
  2598.  1. arithmetic functions such as \(fp)+\(fr), \(fp)-\(fr),
  2599. \(fp)1+\(fr), \(fp)1-\(fr), \(fp)*\(fr), \(fp)floor\(fr), \(fp)mod\(fr),
  2600. \(fp)/\(fr), and \(fp)expt\(fr).
  2601.  
  2602.  2. predicates such as \(fp)eq\(fr), \(fp)eql\(fr), \(fp)equal\(fr), \(fp)zerop\(fr), \(fp)plusp\(fr), \(fp)minusp\(fr), \(fp)=\(fr), \(fp)/=\(fr), \(fp)<\(fr), \(fp)<=\(fr), \(fp)>\(fr), \(fp)>=\(fr), \(fp)char=\(fr), \(fp)char/=\(fr), \(fp)char<\(fr), \(fp)char<=\(fr), \(fp)char>\(fr), and \(fp)char>=\(fr).
  2603.  
  2604.  3. sequence processing functions that receive or return one or more
  2605. fixnum values, such as \(fp)nth\(fr), \(fp)nthcdr\(fr), \(fp)length\(fr), and \(fp)elt\(fr).
  2606.  
  2607.  4. array access functions such as \(fp)svref\(fr), \(fp)char\(fr), \(fp)schar\(fr), and \(fp)aref\(fr) (see below).
  2608.  
  2609.  5. system-internal functions for array update (see below).
  2610.  
  2611.  6. type-specific functions such as \(fp)char-code\(fr), \(fp)code-char\(fr), and \(fp)float\(fr).
  2612.  
  2613.      As mentioned in Section 2.5.1, array elements are represented in one of the six ways depending
  2614. on the type of the array.  By supplying appropriate array type declarations, array access and update
  2615. operations can handle raw data stored in arrays.  For example,
  2616. \(reserve 13)\(fp)
  2617.     (let ((a (make-array n :element-type 'fixnum))
  2618.           (sum 0))
  2619.          (declare (type (array fixnum) a)
  2620.                   (fixnum sum))
  2621.       (dotimes (i n)             ;;; Array initialization.
  2622.                (declare (fixnum i))
  2623.          (setf (aref a i) i))
  2624.       ....
  2625.       (dotimes (i n)             ;;; Summing up the elements.
  2626.                (declare (fixnum i))
  2627.          (setq sum (+ (aref a i) sum)))
  2628.       ....
  2629.       )
  2630. \(fr)
  2631. The \(fp)setf\(fr) form replaces the \(fp)i\(fr)-th element of the
  2632. array \(fp)a\(fr) by the raw fixnum value of \(fp)i\(fr).  The
  2633. \(fp)aref\(fr) form retrieves the raw fixnum datum stored
  2634. in \(fp)a\(fr).  This raw datum is then added to the raw fixnum
  2635. value of the fixnum variable \(fp)sum\(fr), producing the raw fixnum datum to be stored
  2636. in \(fp)sum\(fr).  The similar raw data handling is possible for
  2637. arrays of types
  2638. \(fp)(array fixnum)\(fr), \(fp)(vector fixnum)\(fr),
  2639. \(fp)(array string-char)\(fr), \(fp)string\(fr),
  2640. \(fp)(array short-float)\(fr), \(fp)(vector short-float)\(fr),
  2641. \(fp)(array long-float)\(fr), and \(fp)(vector long-float)\(fr).
  2642.  
  2643. \(reserve 5)\(fg)
  2644. 7.3.3. Arguments/Values Passing\(set-page pp-7-3-3)
  2645. \(fr)
  2646. Function proclamations \(fp)(function \(fi)function-name\(fp) (\(fi)arg-type1 arg-type2\(fp) ...) \(fi)return-type\(fp) )\(fr)
  2647. or its equivalents give the compiler the
  2648. chance to generate the compiled code so that arguments to the named functions
  2649. and resulted values of the named functions be passed via the C stack, thus
  2650. increasing the efficiency of calls to these functions.  Such arguments/values
  2651. passing via the C stack is possible only if the called function is
  2652. also defined in the same source file.  This is because the code for the
  2653. called function must have two entries:  One entry for arguments/values passing
  2654. via the C stack and another for ordinary arguments/values passing via the
  2655. value stack.  (An ordinary function has only the latter entry.)  When the
  2656. latter entry is used, the arguments on the value stack are pushed onto the
  2657. C stack and then the former entry is used to execute the body of the
  2658. function.  On return from the function, the resulted value on the C stack
  2659. is pushed onto the value stack.  This means that ordinary calls to these
  2660. functions are slower than calls to ordinary functions.
  2661.  
  2662.      One of the merits of arguments/values passing via the C stack is that
  2663. raw data stored in C-stack-allocated variables can be passed directly to
  2664. other functions and raw data returned from functions
  2665. may directly be saved in C-stack-allocated variables or may directly be
  2666. used as arguments to another function.  A good example of this follows.
  2667. \(reserve 12)\(fp)
  2668.     (eval-when (compile)
  2669.       (proclaim '(function tak (fixnum fixnum fixnum) fixnum)))
  2670.  
  2671.     (defun tak (x y z)
  2672.       (declare (fixnum x y z))
  2673.       (if (not (< y x))
  2674.           z
  2675.           (tak (tak (1- x) y z)
  2676.                (tak (1- y) z x)
  2677.                (tak (1- z) x y))))
  2678.  
  2679.     ;;; Call (tak 18 12 6).
  2680. \(fr)
  2681. When \(fp)tak\(fr) is called with the arguments \(fp)18\(fr), \(fp)12\(fr),
  2682. and \(fp)6\(fr), the raw fixnum data of the arguments are set to the
  2683. parameters \(fp)x\(fr), \(fp)y\(fr), \(fp)z\(fr) which are allocated on the
  2684. C stack.  After that, only
  2685. raw data on the C stack are used to perform the execution:  No cell pointers
  2686. are newly allocated nor even referenced.  Arguments and resulted values for
  2687. recursive calls to \(fp)tak\(fr) are passed via the C stack, and the
  2688. built-in functions \(fp)<\(fr) and \(fp)1-\(fr) directly operate on the
  2689. raw data.  Only at the return from the top-level call of \(fp)tak\(fr),
  2690. the resulted raw data value (which happens to be \(fp)7\(fr)) is reallocated
  2691. on the heap.  Note that both the \(fp)function\(fr)
  2692. proclamation and the
  2693. local \(fp)fixnum\(fr) declaration are necessary to obtain the optimal
  2694. code.  The \(fp)function\(fr) proclamation is necessary for arguments/values
  2695. passing via the C stack and the \(fp)fixnum\(fr) declaration is necessary to
  2696. allocate the parameters onto the C stack.
  2697.  
  2698.  
  2699. \(fg) 
  2700.  
  2701. \(ce)Chapter 8. Operating System Interface
  2702. \(set-page pp-8)
  2703. \(fr)
  2704.  
  2705.      KCL provides the following facilities that are not
  2706. defined in the \(fi)Common Lisp Reference Manual\(fr).
  2707.  
  2708.  
  2709. \(fp)save\(ri 'save)\(fi) filename\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2710. \(fp)save\(fr) saves the current memory
  2711. image into a program file \(fi)filename\(fr).  After saving the memory image,
  2712. the KCL process terminates immediately.  To execute the saved program file,
  2713. specify the full pathname of the file, as indicated in the example below.
  2714.  
  2715.  
  2716. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  2717.  
  2718. In KCL/AOS, if the filename does not contain the filetype \(fp).pr\(fr),
  2719. then the program file
  2720. is given the name \(fi)filename\(fp).pr\(fr).  Also \(fp)save\(fr) saves a
  2721. symbol table file with
  2722. the filetype \(fp).st\(fr).  When the program file is executed,
  2723. execution begins
  2724. at the top-level of KCL.  Even if there were streams that were open at
  2725. the call of \(fp)save\(fr),
  2726. these streams are not effective when the program file
  2727. is executed.  The function \(fp)save\(fr) of KCL/AOS does not terminate
  2728. the KCL process.
  2729.  
  2730. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  2731.  
  2732.  
  2733. \(endd)
  2734.      Example:
  2735. \(fp)
  2736.     >(defun plus (x y) (+ x y))
  2737.     plus
  2738.  
  2739.     >(save "savefile")
  2740.     %
  2741.  
  2742.     % pwd
  2743.     /usr/hagiya
  2744.     % /usr/hagiya/savefile
  2745.  
  2746.     >(plus 2 3)
  2747.     5
  2748.  
  2749.     >(bye)
  2750.     Bye.
  2751.     %
  2752. \(fr)
  2753.  
  2754. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  2755.  
  2756. Here is the example of \(fp)save\(fr) in
  2757. KCL/AOS.
  2758. \(fp)
  2759.     >(defun plus (x y) (+ x y))
  2760.     plus
  2761.  
  2762.     >(save "savefile")
  2763.     t
  2764.  
  2765.     >(bye)
  2766.     Bye.
  2767.     )
  2768.  
  2769.     ) X SAVEFILE
  2770.  
  2771.     >(plus 2 3)
  2772.     5
  2773.  
  2774.     >(bye)
  2775.     Bye.
  2776.     )\(fr)
  2777.  
  2778. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  2779.  
  2780.  
  2781. \(fp)system\(ri 'system) \(fi)string\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2782. Executes a Shell command as if \(fi)string\(fr) is an input to the Shell.  On return from the Shell command, \(fp)system\(fr) returns the exit code
  2783. of the command as an integer.
  2784.  
  2785.  
  2786. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  2787.  
  2788. This function is not supported in KCL/AOS.  Use instead those functions
  2789. specific to KCL/AOS described below.
  2790.  
  2791. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  2792.  
  2793. \(endd)
  2794.  
  2795. \(fp)bye\(ri 'bye) &optional\(fi) exit-code\(fr)\(ra)[\(fi)Function\(fr)]
  2796. \(fp)by\(ri 'by)  &optional\(fi) exit-code\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2797. Terminates KCL and returns the \(fi)exit-code\(fr) to the parent process.  \(fi)exit-code\(fr) must be an integer and its default value is \(fp)0\(fr).
  2798. \(endd)
  2799.  
  2800.  
  2801. \(fr)---------------------- \(fi)Note to KCL/AOS users\(fr) ----------------------
  2802.  
  2803. The functions \(fp)bye\(fr) and \(fp)by\(fr) of KCL/AOS accept a string
  2804. instead of an \(fi)exit-code\(fr).  If \(fi)string\(fr) is supplied, these functions return the \(fi)string\(fr) to the father as the termination message.
  2805.  
  2806. \(fr)--------------------------- \(fi)End of Note\(fr) ----------------------------
  2807.  
  2808.  
  2809. The following functions \(fp)process\(ri 'process)\(fr), 
  2810. \(fp)termination-message\(ri 'termination-message)\(fr), and
  2811. \(fp)last-termination-message\(ri 'last-termination-message)\(fr)
  2812. are specific to KCL/AOS and are not supported in KCL on Unix.
  2813.  
  2814. \(fp)process\(ri 'process)\(fi) progname \(sm)\(fp)&optional \(fi)ipc-message\(fr)\(ra)[\(fi)Function\(fr)]
  2815. \(fp)&key \(sm):block\(ri ':block) :console\(ri ':console) :debug\(ri ':debug) :dir\(ri ':dir)\(br)
  2816. \(fp):input\(ri ':input) :output\(ri ':output) :username\(ri ':username)\(br)
  2817. :list\(ri ':list) :data\(ri ':data) :ioc\(ri ':ioc)\(fr)\(rm)\(bd)\(br)
  2818. This function is defined only in KCL/AOS.  \(fp)process\(fr) creates a process in the way as specified by
  2819. its arguments.
  2820.  
  2821.     \(fi)progname\(fr)        \(sm)The name of the process to create.  Must be a string.\(rm)
  2822.  
  2823.     \(fi)ipc-message\(fr)    \(sm)The IPC message passed to the process.  Must be a string.  Arguments in the message must be separated with commas '\(fp),\(fr)'.\(rm)
  2824.  
  2825.     \(fp):block\(fr)        \(sm)If non-\(fp)nil\(fr), KCL blocks its execution while the son executes.  Defaults to \(fp)t\(fr).\(rm)
  2826.  
  2827.     \(fp):console\(fr)    \(sm)The name of the file to be associated to \(fp)@console\(fr).  Must be a string.  No file is associated if \(fp):console\(fr) is not specified and if the \(fp):ioc\(fr) argument (see below) is specified with a non-\(fp)nil\(fr) value.  \(fp):console\(fr) supercedes \(fp):ioc\(fr).\(rm)
  2828.  
  2829.     \(fp):debug\(fr)        If non-\(fp)nil\(fr), the son runs in the debug mode.
  2830.  
  2831.     \(fp):input\(fr)        \(sm)The name of the file to be associated to \(fp)@input\(fr).  Must be a string.  No file is associated if \(fp):input\(fr) is not specified and if the \(fp):ioc\(fr) argument (see below) is specified with a non-\(fp)nil\(fr) value.  \(fp):input\(fr) supercedes \(fp):ioc\(fr).\(rm)
  2832.  
  2833.     \(fp):output\(fr)        \(sm)The name of the file to be associated to \(fp)@output\(fr).  Must be a string.  No file is associated if \(fp):output\(fr) is not specified and if the \(fp):ioc\(fr) argument (see below) is specified with a non-\(fp)nil\(fr) value.  \(fp):output\(fr) supercedes \(fp):ioc\(fr).\(rm)
  2834.  
  2835.     \(fp):username\(fr)    \(sm)The user-name of sub-process.  Must be a string.  If not specified, the current user-name is used.\(rm)
  2836.  
  2837.     \(fp):list\(fr)        \(sm)If a string, the name of the file to be associated to \(fp)@list\(fr).  If \(fp)t\(fr), the file currently associated to \(fp)@list\(fr) is used.  If \(fp)nil\(fr), or if not specified, no list file is passed to the son.\(rm)
  2838.  
  2839.     \(fp):data\(fr)        \(sm)If a string, the name of the file to be associated to \(fp)@data\(fr).  If \(fp)t\(fr), the file currently associated to \(fp)@data\(fr) is used. If \(fp)nil\(fr), or if not specified, no data file is passed to the son.\(rm)
  2840.  
  2841.     \(fp):ioc\(fr)        \(sm)If non-\(fp)nil\(fr), current \(fp)@input\(fr), \(fp)@output\(fr), and \(fp)@console\(fr) files are passed to the son.  If not specified, these files are not passed unless specified by the \(fp):console\(fr), \(fp):input\(fr), or \(fp):output\(fr) arguments.\(rm)
  2842. \(endd)
  2843.      Example:
  2844. \(fp)
  2845.     >(process ":cli.pr")
  2846.  
  2847.     AOS/VS CLI  REV 03f.03.00.00             19-APRIL-84     12:00:00
  2848.     )by
  2849.     AOS/VS CLI  TERMINATING                  19-APRIL-84     12:00:00
  2850.     t
  2851.  
  2852.     >
  2853. \(fr)
  2854.  
  2855. \(fp)termination-message\(ri 'termination-message)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2856. This function is defined only in KCL/AOS.  \(fp)termination-message\(fr) returns a string consisting of the termination message of a son.  Used in connection with the function \(fp)process\(fr).
  2857. \(endd)
  2858.  
  2859. \(fp)last-termination-message\(ri 'last-termination-message)\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  2860. This function is defined only in KCL/AOS.  \(fp)last-termination-message\(fr)
  2861. flushes all the messages currently spooled and
  2862. returns the last termination message.
  2863. \(endd)
  2864.  
  2865. \(fg) 
  2866.  
  2867. \(ce)Chapter 9. Macros
  2868. \(set-page pp-9)
  2869. \(fr)
  2870. \(fg)
  2871. 9.1. System Macros\(set-page pp-9-1)
  2872. \(fr)
  2873. The KCL interpreter implements the following system macros as if
  2874. they were special forms.  That is, macro forms of the following macros are
  2875. directly evaluated without being macro-expanded.
  2876. \(reserve 6)\(fp)
  2877.     and       case      cond      decf      defmacro  defun
  2878.     do        do*       dolist    dotimes   incf      locally
  2879.     loop      multiple-value-bind           multiple-value-list
  2880.     multiple-value-setq           or        pop       prog
  2881.     prog*     prog1     prog2     psetq     push      return
  2882.     setf      unless    when
  2883. \(fr)
  2884. For these macro forms, the functions \(fp)macro-function\(fr) and
  2885. \(fp)special-form-p\(fr) both return non-\(fp)nil\(fr) values:
  2886. \(fp)macro-function\(fr) returns the macro expansion function
  2887. and \(fp)special-form-p\(fr) returns \(fp)t\(fr).  Of course,
  2888. functions such as \(fp)macroexpand\(ri 'macroexpand)\(fr) and
  2889. \(fp)macroexpand-1\(ri 'macroexpand-1)\(fr) will successfully
  2890. expand macro forms for these system macros.
  2891.  
  2892. \(reserve 5)\(fg)
  2893. 9.2. Defmacro Lambda-Lists\(set-page pp-9-2)
  2894. \(fr)
  2895. A \(fi)defmacro lambda-list\(fr) is a lambda-list-like construct that is used
  2896. as the third element in the \(fp)defmacro\(fr) form,
  2897. \(fp)
  2898.     (defmacro \(fi)name\(fp) \(fi)defmacro-lambda-list\(fp) \(fr){\(fi)declaration\(fp) \(fr)|\(fp) \(fi)doc-string\(fr)}*\(fp) \(fr){\(fi)form\(fr)}* \(fp))\(fr)
  2899.  
  2900. The description of defmacro lambda-lists in the \(fi)Common Lisp Reference Manual\(fr) is quite
  2901. ambiguous.  KCL employs the
  2902. following syntax.
  2903. \(reserve 12)
  2904. The complete syntax of a defmacro lambda-list is:
  2905. \(fp)
  2906. ( \(fr)[\(fp) &whole \(fi)var\(fp) \(fr)]\(fp)
  2907.   \(fr)[\(fp) &environment \(fi)var\(fp) \(fr)]\(fp)
  2908.   \(fr){\(fp) \(fi)pseudo-var\(fp) \(fr)}*\(fp)
  2909.   \(fr)[\(fp) &optional \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)pseudo-var\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)[\(fp) \(fi)pseudo-var\(fp) \(fr)]\(fp) \(fr)]\(fp) ) \(fr)}*\(fp) \(fr)]\(fp)
  2910.   \(fr){\(fp)  \(fr)[\(fp) \(fr){\(fp) &rest \(fr)|\(fp) &body \(fr)}\(fp) \(fi)pseudo-var\(fp) \(fr)]\(fp)
  2911.      \(fr)[\(fp) &key \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)keyword\(fp) \(fi)pseudo-var\(fp) ) \(fr)}\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)[\(fp) \(fi)pseudo-var\(fp) \(fr)] ]\(fp) ) \(fr)}*\(fp)
  2912.         \(fr)[\(fp) &allow-other-keys \(fr)] ]\(fp)
  2913.      \(fr)[\(fp) &aux \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)pseudo-var\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)]\(fp) ) \(fr)}*\(fp) \(fr)]\(fp)
  2914.   \(fr)|\(fp)  . \(fi)var\(fp) \(fr)}\(fp)
  2915.  )
  2916. \(fr)
  2917. where \(fi)pseudo-var\(fr) is either a symbol or a list of the following form:
  2918. \(reserve 8)\(fp)
  2919. ( \(fr){\(fp) \(fi)pseudo-var\(fp) \(fr)}*\(fp)
  2920.   \(fr)[\(fp) &optional \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)pseudo-var\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)[\(fp) \(fi)pseudo-var\(fp) \(fr)]\(fp) \(fr)]\(fp) ) \(fr)}*\(fp) \(fr)]\(fp)
  2921.   \(fr){\(fp)  \(fr)[\(fp) \(fr){\(fp) &rest \(fr)|\(fp) &body \(fr)}\(fp) \(fi)pseudo-var\(fp) \(fr)]\(fp)
  2922.      \(fr)[\(fp) &key \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)keyword\(fp) \(fi)pseudo-var\(fp) ) \(fr)}\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)[\(fp) \(fi)pseudo-var\(fp) \(fr)] ]\(fp) ) \(fr)}*\(fp)
  2923.         \(fr)[\(fp) &allow-other-keys \(fr)] ]\(fp)
  2924.      \(fr)[\(fp) &aux \(fr){\(fp) \(fi)var\(fp) \(fr)|\(fp) ( \(fi)pseudo-var\(fp) \(fr)[\(fp) \(fi)initform\(fp) \(fr)]\(fp) ) \(fr)}*\(fp) \(fr)]\(fp)
  2925.   \(fr)|\(fp)  . \(fi)var\(fp) \(fr)}\(fp)
  2926.  )
  2927. \(fr)
  2928. The defmacro lambda-list keyword \(fp)&whole\(ri '&whole)\(fr) may
  2929. appear only at the top-level,
  2930. first in the defmacro lambda-list.  It is not allowed within
  2931. \(fi)pseudo-var\(fr).  Use of the \(fp)&whole\(fr) keyword does not affect
  2932. the processing of the rest of the defmacro lambda-list:
  2933. \(fp)
  2934.     (defmacro foo (&whole w x y) ... )
  2935. \(fr)
  2936. and
  2937. \(fp)
  2938.     (defmacro foo (x y) ... )
  2939. \(fr)
  2940. both bind the variables \(fp)x\(fr) and \(fp)y\(fr) to the second and the
  2941. third elements, respectively, of macro forms of \(fp)foo\(fr).
  2942.  
  2943.      The defmacro lambda-list keyword \(fp)&environment\(ri '&environment)\(fr) may
  2944. appear only at the
  2945. top-level, first in the defmacro lambda-list if \(fp)&whole\(ri '&whole)\(fr) is not
  2946. supplied, or immediately after the variable that follows \(fp)&whole\(fr), if
  2947. \(fp)&whole\(fr) is supplied.  \(fp)&environment\(fr) is not allowed within
  2948. \(fi)pseudo-var\(fr).  Like \(fp)&whole\(fr), use of \(fp)&environment\(fr)
  2949. does not affect the processing of the rest of
  2950. the defmacro lambda-list.  If an \(fp)&environment\(fr) parameter is supplied and if this parameter is
  2951. not used at all, then the KCL compiler
  2952. will issue a warning.  To suppress the warning, just remove
  2953. the parameter from the defmacro lambda-list,
  2954. or add an \(fp)ignore\(fr) declaration.
  2955.  
  2956.      The defmacro lambda-list keyword \(fp)&body\(fr) is completely equivalent to
  2957. the \(fp)&rest\(fr) keyword.  KCL takes no special action for \(fp)&body\(fr)
  2958. parameters.
  2959.  
  2960.      Although useless, KCL allows supplied-p parameters
  2961. to be destructured.  This is useless because supplied-p parameters never
  2962. be bound to a non-empty
  2963. list.  Our intention is to stick to the specification in
  2964. the \(fi)Common Lisp Reference Manual\(fr) as far as possible, even if it is
  2965. silly to do so.
  2966.  
  2967.      Like for ordinary lambda-lists, the interpreter detects invalid arguments to
  2968. macro expansion functions.  When a parameter is destructured, the
  2969. structure of the corresponding argument is also checked.  Such
  2970. runtime argument checking may or may not be embedded in compiled code,
  2971. depending on the environment when the code was generated.  If
  2972. the code was generated while the \(fp)safety\(ri 'safety)\(fr)
  2973. optimize level is zero (that is,
  2974. while the value of \(fp)(proclamation '(optimize (safety 0)))\(fr) is
  2975. \(fp)t\(fr)), then the generated code does not perform argument
  2976. checking at all.  Otherwise, the compiled
  2977. code does check the validity of arguments.
  2978.  
  2979. \(fg) 
  2980.  
  2981. \(ce)Chapter 10. The C Language Interface
  2982. \(set-page pp-10)
  2983. \(fr)
  2984. This chapter describes the facility of KCL to interface the C language
  2985. and KCL.  With
  2986. this facility, the user can arrange his or her C-language programs
  2987. so that they can be
  2988. invoked from KCL.  In addition, the user can write
  2989. Lisp function definitions in the C
  2990. language to increase runtime efficiency.
  2991.  
  2992.      The basic idea of interfacing the C language is this:  As mentioned
  2993. in Chapter 6, the
  2994. KCL compiler, given a Lisp source file, creates an intermediate C-language
  2995. program file,
  2996. called \(fi)c-file\(fr), which is then compiled by the C-language compiler
  2997. to obtain the final fasl-file.  Usually, the c-file consists of C-language
  2998. function definitions.  The first C-language function in the c-file is the
  2999. "initializer", which is executed when the fasl file is loaded, and the other
  3000. C-language functions are the C versions of the Lisp functions (including
  3001. macro expansion functions) defined in the source file.  By using the
  3002. top-level macros \(fp)Clines\(fr) and \(fp)defCfun\(fr) described below,
  3003. the user can direct the compiler to insert his or her own C-language function
  3004. definitions and/or C-language preprocessor macros such as
  3005. \(fp)#define\(fr) and \(fp)#include\(fr) into the c-file.  In order that
  3006. such C-language functions be invoked from KCL, another top-level macro
  3007. \(fp)defentry\(ri 'defentry)\(fr) is used.  This macro defines
  3008. a Lisp function whose body consists of the calling
  3009. sequence to the specified C-language function.
  3010.  
  3011.      The C-language function definitions are placed in the c-file in the
  3012. order of the corresponding Lisp functions defined
  3013. in the source file.  That is, the C code for the first Lisp function comes
  3014. first, the C code for the second Lisp function comes second, and so on.  If
  3015. a \(fp)Clines\(fr) or \(fp)defCfun\(fr) macro form appears between two
  3016. Lisp function definitions in the source file, then the C code specified by
  3017. the macro is placed in between the C code for the Lisp functions.
  3018.  
  3019.      We define some terminology here which are used throughout
  3020. this Chapter.  A \(fi)C-id\(fr) is either a Lisp string consisting of a
  3021. valid C-language identifier, or a Lisp symbol
  3022. whose print-name, with all its alphabets turned into lower cases,
  3023. is a valid C identifier.  Thus the
  3024. symbol \(fp)foo\(fr) is equivalent to the string \(fp)"foo"\(fr)
  3025. when used as a C-id.  Similarly, a \(fi)C-expr\(fr) is a
  3026. string or a symbol that may be regarded as a C-language expression.  A \(fi)C-type\(fr) is one of
  3027. the Lisp symbols\(fp) int\(fr), \(fp)char\(fr), \(fp)float\(fr), \(fp)double\(fr), and\(fp) object\(fr).  Each corresponds to a data
  3028. type in the C language; \(fp)object\(fr) is the type of Lisp object and
  3029. other C-types are primitive
  3030. data types in the C language.
  3031.  
  3032.  
  3033. \(fp)Clines\(ri 'Clines)\(fr) {\(fi)string\(fr)}*\(ra)[\(fi)Macro\(fr)]\(bd)
  3034. When the KCL compiler encounters a macro form \(fp)(Clines\(fi) string1\(fr) ... \(fi)stringn\(fp))\(fr), it
  3035. simply outputs the \(fi)string\(fr)s into the c-file.  The arguments are not evaluated and
  3036. each argument must be a string.  Each \(fi)string\(fr) may consist of any number of lines,
  3037. and separate lines in the \(fi)string\(fr) are placed in separate lines in the c-file.  In addition,
  3038. each \(fi)string\(fr) opens a fresh line in the c-file, i.e., the first character in the \(fi)string\(fr) is
  3039. placed at the first column of a line.  Therefore, C-language preprocessor commands
  3040. such as \(fp)#define\(fr) and \(fp)#include\(fr) will be recognized as such by the C compiler, if the '\(fp)#\(fr)' sign
  3041. appears as the first character of the \(fi)string\(fr) or as the first
  3042. character of a
  3043. line within the \(fi)string\(fr).
  3044.  
  3045.      In order to clearly distinguish C code from other part of Lisp programs,
  3046. we, the implementors of KCL, make it our rule to start each C code line
  3047. with a percent sign '\(fp)%\(fr)'.  We define \(fp)%\(fr) as a read macro
  3048. which returns the rest of the line as a string.  For \(fp)\(fr)example,
  3049. \(reserve 12)\(fp)
  3050.     ;;; C version of TAK.
  3051.     (Clines
  3052.  
  3053.     %    int tak(x, y, z)
  3054.     %    int x, y, z;
  3055.     %    {    if (y >= x) return(z);
  3056.     %        else return(tak(tak(x-1, y, z),
  3057.     %                        tak(y-1, z, x),
  3058.     %                        tak(z-1, x, y)));
  3059.     %    }
  3060.  
  3061.     )
  3062. \(fr)
  3063. Of course, the user may instead enclose each C code line or the
  3064. whole C code with
  3065. double quotes, but we recommend the use of
  3066. the percent sign read macro.  Since
  3067. the percent sign read macro is not a standard read macro, the users must
  3068. define this read macro by themselves.  We use the following definition.
  3069. \(reserve 3)\(fp)
  3070.     (set-macro-character
  3071.         #\\%
  3072.         #'(lambda (stream char) (values (read-line stream)))))
  3073. \(fr)
  3074. Here, the lambda-expression returns the first value of \(fp)read-line\(ri 'read-line)\(fr) by using \(fp)values\(ri 'values)
  3075. \(fr)as a filter.
  3076.  
  3077.      When interpreted, a \(fp)Clines\(fr) macro form expands to \(fp)nil\(fr).
  3078. \(endd)
  3079.  
  3080. \(fp)defentry\(ri 'defentry) \(fi)function\(fr) \(fi)parameter-list\(fr) \(fi)C-function\(fr)\(ra)[\(fi)Macro\(fr)]\(bd)
  3081. \(fp)defentry\(fr) defines a Lisp function whose body consists of
  3082. the calling sequence to a
  3083. C-language function.  \(fi)function\(fr) is the name of the Lisp function
  3084. to be defined, and\(fi) C-function\(fr) specifies the C function
  3085. to be invoked.  \(fi)C-function\(fr) must be either a list
  3086. \(fp)(\(fi)type\(fp) \(fi)C-id\(fp))\(fr) or \(fi)C-id\(fr),
  3087. where \(fi)type\(fr) and \(fi)C-id\(fr) are the type and
  3088. the name of the C function.  \(fi)type\(fr) must be a C-type or
  3089. the symbol \(fp)void\(fr) which means that the C function returns
  3090. no value.  \(fp)(object \(fi)C-id\(fp))\(fr) may be abbreviated
  3091. as \(fi)C-id\(fr).  \(fi)parameter-list\(fr) is a list of C-types
  3092. for the parameters of the C function.  For example,
  3093. the following \(fp)defentry
  3094. \(fr)form defines a Lisp function \(fp)tak\(fr) from
  3095. which the C function \(fp)tak\(fr) above is called.
  3096. \(fp)
  3097.     (defentry tak (int int int) (int tak))
  3098. \(fr)
  3099. The Lisp function \(fp)tak\(fr) defined by this \(fp)defentry\(fr) form
  3100. requires three arguments.  The arguments are converted to
  3101. \(fp)int\(fr) values before they are passed to the C function.  On return
  3102. from the C
  3103. function, the returned \(fp)int\(fr) value is converted
  3104. to a Lisp integer (actually a fixnum)
  3105. and this fixnum will be returned as the value
  3106. of the Lisp function.  See below for
  3107. type conversion between Lisp and the C language.
  3108.  
  3109.      A \(fp)defentry\(fr) form is treated in the above way only when it appears as a top-level form of a Lisp source file.  Otherwise, a \(fp)defentry\(fr) form expands to \(fp)nil\(fr).
  3110. \(endd)
  3111.  
  3112. \(fp)defla\(ri 'defla) \(fi)name\(fr) \(fi)lambda-list\(fr) {\(fi)declaration\(fr) | \(fi)doc-string\(fr)}* {\(fi)form\(fr)}*\(ra)[\(fi)Macro\(fr)]\(bd)
  3113. When interpreted, \(fp)defla\(fr) is exactly the same as \(fp)defun\(fr).  That is, \(fp)(defla\(fr) \(fi)name
  3114. lambda-list\(fr) . \(fi)body\(fp))\(fr)
  3115. expands to \(fp)(defun\(ri 'defun)\(fr) \(fi)name lambda-list\(fr) . \(fi)body\(fp))\(fr).  However, \(fp)defla
  3116. \(fr)forms are completely ignored by the compiler; no C-language code will be
  3117. generated for \(fp)defla\(fr) forms.  The primary use of \(fp)defla\(fr) is to define a Lisp function
  3118. in two ways within a single Lisp source file; one in the C language and the other in
  3119. Lisp.  \(fp)defla\(fr) is short for\(fi) DEF\(fr)ine \(fi)L\(fr)isp\(fi) A\(fr)lternative.
  3120.  
  3121.      Suppose you have a Lisp source file whose contents are:
  3122. \(reserve 12)\(fp)
  3123.     ;;; C version of TAK.
  3124.     (Clines
  3125.  
  3126.     %    int tak(x, y, z)
  3127.     %    int x, y, z;
  3128.     %    {    if (y >= x) return(z);
  3129.     %        else return(tak(tak(x-1, y, z),
  3130.     %                        tak(y-1, z, x),
  3131.     %                        tak(z-1, x, y)));
  3132.     %    }
  3133.  
  3134.     )
  3135. \(reserve 2)
  3136.     ;;;  TAK calls the C function tak defined above.
  3137.     (defentry tak (int int int) (int tak))
  3138. \(reserve 7)
  3139.     ;;;  The alternative Lisp definition of TAK.
  3140.     (defla tak (x y z)
  3141.       (if (>= y x)
  3142.           z
  3143.           (tak (tak (1- x) y z)
  3144.                (tak (1- y) z x)
  3145.                (tak (1- z) x y))))
  3146. \(fr)
  3147. When this file is loaded into KCL, the interpreter uses the Lisp version of the \(fp)tak
  3148. \(fr)definition.  Once this file have been compiled, and when the generated fasl file is
  3149. loaded into KCL, function call to tak is actually the call to the C version of \(fp)tak\(fr).
  3150. \(endd)
  3151.  
  3152. \(fp)defCfun\(ri 'defCfun) \(fi)header\(fr) \(fi)n\(fr) {\(fi)element\(fr)}*\(ra)[\(fi)Macro\(fr)]\(bd)
  3153. \(fp)defCfun\(fr) defines a C-language function which calls
  3154. Lisp functions and/or which
  3155. handles Lisp objects.  \(fi)header\(fr) is a string consisting of the C
  3156. code for
  3157. \(reserve 3)
  3158.     the optional \(fi)type-specifier\(fr) of the C function,
  3159.     the \(fi)function-declarator\(fr) of the C function, and
  3160.     the \(fi)type-decl-list\(fr) of the parameters to the C function.
  3161.  
  3162. (For the C-language terminology, refer to \(fi)The C Programming Language\(fr) by Brian W.  Kernighan and Dennis M. Ritchie.)  The rest of the C function
  3163. definition, i.e., the
  3164. \(fi)function-statement\(fr), is given by\(fi) element\(fr)s.  Each \(fi)element\(fr) may be a string, in which case
  3165. the string is treated in the same way as the arguments to the \(fp)Clines\(fr) macro.  Or else,
  3166. the \(fi)element\(fr) is a list
  3167. \(fp)((\(fi)name arg1\(fr) ... \(fi)argn\(fp)) \(fi)place1\(fr) ... \(fi)placem\(fp))\(fr).  The compiler
  3168. translates this list into a calling sequence to the Lisp function
  3169. whose name is \(fi)name\(fr).  As will be
  3170. mentioned later, \(fi)name\(fr) may be \(fp)quote\(ri 'quote)\(fr),
  3171. but \(fi)name\(fr) may not be the name of other special
  3172. form or a macro.  The \(fi)arg\(fr)s specify the arguments to the function
  3173. and the \(fi)place\(fr)s
  3174. specify where the values should go.  Thus the list-formed \(fi)element\(fr) could be regarded
  3175. as something like the Lisp form:
  3176. \(reserve 3)\(fp)
  3177.     (multiple-value-setq
  3178.         (\(fi)place1\(fr) ... \(fi)placem\(fp))
  3179.         (\(fi)name\(fr) \(fi)arg1\(fr) ... \(fi)argn\(fp))).
  3180. \(fr)
  3181. Each \(fi)arg\(fr) is a list\(fp) (\(fi)C-type\(fp) \(fi)C-expr\(fp))\(fr), where \(fi)C-expr\(fr) is any C-language expression of the
  3182. type \(fi)C-type\(fr).  If \(fi)type\(fr) is \(fp)object\(fr), then \(fi)arg\(fr) may be written simply as \(fi)C-expr\(fr).  Similarly,
  3183. each \(fi)place\(fr) is a list\(fp) (\(fi)C-type\(fp) \(fi)C-expr\(fp))\(fr), or it may be abbreviated as\(fi) C-expr\(fr) if \(fi)C-type\(fr) is
  3184. \(fp)object\(fr).  The \(fi)C-expr\(fr) in this case is any \(fi)lvalue\(fr) (in the terminology of the C
  3185. language), i.e., it may be any valid C-language code that can be written at the left
  3186. side of an assignment.
  3187.  
  3188.      The function call is performed as follows.  The \(fi)arg\(fr)s are evaluated, and the
  3189. values are sent to the specified Lisp function after type conversion from C to Lisp.  On return from the called Lisp function, each returned value is assigned to the
  3190. corresponding \(fi)place\(fr), i.e., the first returned value goes to \(fi)place1\(fr), the second to \(fi)place2\(fr),
  3191. and so on.  If there are more \(fi)place\(fr)s than the values returned, extra values of \(fp)nil
  3192. \(fr)are assigned to the remaining \(fi)place\(fr)s.  If there are more values than \(fi)place\(fr)s, the
  3193. excess values are simply discarded.  If necessary, Lisp-to-C type conversion may
  3194. take place before each returned value is assigned.
  3195.  
  3196.      If the Lisp function is called just for side-effects, then the list-formed \(fi)element
  3197. \(fr)may be abbreviated as a one-level list\(fp) (\(fi)name\(fp) \(fi)arg1\(fr) ... \(fi)argn\(fp))\(fr).
  3198.  
  3199.      As a special case, if a list-formed \(fi)element\(fr) is of the form\(fp) ((quote \(fi)value\(fp)) \(fi)place\(fr)),
  3200. the Lisp object \(fi)value\(fr) is assigned to \(fi)place\(fr).  Here \(fi)value\(fr) may be any Lisp object.
  3201.  
  3202.      The following \(fp)defCfun\(fr) form defines the C function\(fp) silly\(fr) which adds \(fp)100\(fr) to
  3203. the value of the parameter \(fp)x\(fr) and prints the result in three different ways.  The
  3204. second argument to\(fp) defCfun\(fr) will be described later, and the user may ignore it.
  3205. \(reserve 8)\(fp)
  3206.     (defCfun "silly(x) int x;" 0
  3207.     %    int y;
  3208.         ((+ (int x) (int "100")) (int y))
  3209.     %    printf("\\n%d", y);
  3210.     %    y = x+100;
  3211.         (print (int y))
  3212.         (print (int "x+100"))
  3213.     )
  3214. \(fr)
  3215.      When a C function handles Lisp objects (i.e., data of type \(fp)object\(fr)), the user
  3216. should be careful enough so that the objects may not be garbage-collected.  This is
  3217. because the garbage collector of KCL does not take care of Lisp objects used in the
  3218. C function.  See the following C function which is assumed to return a two-element
  3219. list consisting of its two arguments.
  3220. \(reserve 7)\(fp)
  3221.     (defCfun "object list2(x,y) object x,y;" 0
  3222.     %    object z;
  3223.         ('nil z)
  3224.         ((cons y z) z)
  3225.         ((cons x z) z)
  3226.     %    return(z);
  3227.     )
  3228. \(fr)
  3229. When invoked, \(fp)list2\(fr) first sets \(fp)nil\(fr) to the variable \(fp)z\(fr), conses \(fp)y\(fr) to \(fp)z\(fr), and then conses
  3230. \(fp)x\(fr).  Each time \(fp)cons\(fr) is called, a new cons cell is allocated and the pointer to this cell
  3231. is stored in \(fp)z\(fr).  However, there is no way to inform
  3232. the garbage collector that the cells are referenced from the C variable \(fp)z\(fr).  Suppose
  3233. that the cons cell allocated by the first \(fp)cons\(fr) is the last cons cell available at that
  3234. time.  Then, during execution of the second call to \(fp)cons\(fr), the garbage collector
  3235. begins to run and, unfortunately, the cons cell in \(fp)z\(fr) will be destroyed so that the
  3236. cell can be recycled for further use.
  3237.  
  3238.      To prevent a Lisp object from being unexpectedly garbage collected, the user
  3239. must save the object in some place that is recognized by the garbage collector.  The
  3240. second parameter \(fi)n\(fr) to \(fp)defCfun\(fr) is used to reserve \(fi)n\(fr) such places for each call to the
  3241. C function.  In the body of the C function, these reserved places are referenced as
  3242. \(fp)vs[0]\(fr), ..., \(fp)vs[\(fi)n-1\(fp)]\(fr).  The function \(fp)list2\(fr) above, therefore, should be revised as
  3243. \(fp)\(fr)follows.
  3244. \(reserve 6)\(fp)
  3245.     (defCfun "object list2(x,y) object x,y;" 1
  3246.         ('nil "vs[0]")
  3247.         ((cons y "vs[0]") "vs[0]")
  3248.         ((cons x "vs[0]") "vs[0]")
  3249.     %    Creturn(vs[0]);
  3250.     )
  3251. \(fr)
  3252. Notice that \(fp)return\(fr) is replaced by \(fp)Creturn\(fr).  \(fp)Creturn\(fr) is similar to \(fp)return\(fr) except
  3253. that \(fp)Creturn\(fr) releases the reserved places on
  3254. return from the function.  In the C
  3255. code within a \(fp)defCfun\(fr) form,
  3256. write "\(fp)Creturn(\(fi)value\(fp));\(fr)" instead of
  3257. "\(fp)return(\(fi)value\(fp));\(fr)", and
  3258. write "\(fp)Cexit;\(fr)" instead of "\(fp)return;\(fr)".
  3259.  
  3260.      Again, a \(fp)defCfun\(fr) form has the above meaning only when it appears as a top-level form in a Lisp source file.  Otherwise, the form expands to \(fp)nil\(fr).\(endd)
  3261.  
  3262.      KCL converts a Lisp object into a C-language data by using the Common Lisp function
  3263. \(fp)coerce\(ri 'coerce)\(fr): For the C-type \(fp)int\(fr) (or \(fp)char\(fr)), the object is first coerced to a Lisp integer and
  3264. the least significant 32-bit (or 8-bit) field is used as the C \(fp)int\(fr) (or \(fp)char\(fr)).  For the C-type \(fp)float\(fr) (or \(fp)double\(fr)), the object is coerced to a short-float (or a long-float) and this
  3265. value is used as the C \(fp)float\(fr) (or \(fp)double\(fr)).  Conversion from a C data into a Lisp object is
  3266. obvious: C \(fp)char\(fr), \(fp)int\(fr), \(fp)float\(fr), and \(fp)double\(fr) become the equivalent Lisp character, fixnum,
  3267. short-float, and long-float, respectively.
  3268.  
  3269.      Here we list the complete syntax of \(fp)Clines\(fr), \(fp)defentry\(fr), and \(fp)defCfun\(fr) macro forms.
  3270. \(reserve 2)
  3271.     \(fp)Clines\(fr)-form:
  3272.         \(fp)(Clines \(fr){ \(fi)string\(fr) }* \(fp))
  3273. \(reserve 4)
  3274.     defentry\(fr)-form:
  3275.         \(fp)(defentry \(fi)function-symbol
  3276.             \(fp)( \(fr){ \(fi)C-type\(fr) }*\(fp) )
  3277.             \(fr){ \(fi)C-function-name\(fr) | \(fp)( \(fr){ \(fi)C-type\(fr) | \(fp)void\(fr) } \(fi)C-function-name\(fp) ) \(fr)} \(fp))
  3278. \(reserve 5)
  3279.     defCfun\(fr)-form:
  3280.         \(fp)(defCfun \(fi)string  non-negative-integer
  3281.             \(fr){ \(fi)string
  3282.             \(fr)  | \(fp)(\(fi)function-symbol\(fr) { \(fi)value\(fr) }* \(fp))
  3283.             \(fr)  | \(fp)((\(fi)function-symbol\(fr) { \(fi)value\(fr) }* \(fp)) \(fr){ \(fi)place\(fr) }* \(fp)) \(fr)} \(fp))
  3284. \(reserve 3)
  3285.     \(fr)value:
  3286.     place:
  3287.         { \(fi)C-expr\(fr) | \(fp)(\(fi)C-type C-expr\(fp))\(fr) }
  3288. \(reserve 3)
  3289.     C-function-name:
  3290.     C-expr:
  3291.         { \(fi)string\(fr) | \(fi)symbol\(fr) }
  3292. \(reserve 2)
  3293.     C-type:
  3294.         { \(fp)object\(fr) | \(fp)int\(fr) | \(fp)char\(fr) | \(fp)float\(fr) | \(fp)double\(fr) }
  3295.  
  3296. \(fg) 
  3297.  
  3298. \(ce)Chapter 11. The Editor
  3299. \(set-page pp-11)
  3300. \(fr)
  3301.  
  3302. KCL/AOS is equipped with a screen editor
  3303. FeCl2 (\(fi)F\(fr)ull-screen \(fi)E\(fr)ditor
  3304. as a \(fi)C\(fr)ommon \(fi)L\(fr)isp \(fi)TOO\(fr)l).  FeCl2 is an EMACS-like editor with facilities for Lisp coding.  FeCl2 is invoked from KCL by the function \(fp)ed\(ri 'ed)\(fr)
  3305. and the result of editing can be passed to KCL directly.  For the details of FeCl2 refer to \(fi)The FeCl2 Editor Reference Manual\(fr).
  3306.  
  3307. \(fp)ed\(ri 'ed) &optional\(fi) filename\(fr)\(ra)[\(fi)Function\(fr)]\(bd)
  3308. \(fp)ed\(fr) invokes FeCl2
  3309. and sets the edit file of FeCl2 to \(fi)filename\(fr).  If the filetype of the file is not explicitly specified,
  3310. then the \(fi)filename\(fr) is
  3311. first merged into \(fp)#".lsp"\(fr).
  3312. \(endd)
  3313.  
  3314. The FeCl2 editor is not supported by other versions of KCL.  The function \(fp)ed\(fr) of KCL/VAX, KCL/SUN, and KCL/UST calls the vi editor.  If you hate vi, define your own \(fp)ed\(fr) function using the function
  3315. \(fp)system\(ri 'system)\(fr) described in Chapter 8.  
  3316.  
  3317. \(fg) 
  3318.  
  3319. \(ce)Appendix A. KCL Summary
  3320. \(set-page pp-summary)
  3321. \(fr)
  3322. The following table lists all symbols defined in KCL.  Each line has one of the
  3323. following form.
  3324.  
  3325.        \(fi)symbol\(fr)   [\(fi)kind\(fr)]   \(fi)remark
  3326. \(fr)
  3327. where \(fi)kind\(fr) is Function, Macro, Special (i.e., Special form name),
  3328. Variable, Constant, Symbol, or Keyword.  In the table, some symbols are
  3329. indicated both as a macro and a special form name.  This means
  3330. that, although these symbols are defined to be a macro name
  3331. in the \(fi)Common Lisp Reference Manual\(fr), KCL treats them as
  3332. if they were special forms (see Section 9.1).  The pages in the remark
  3333. refer to pages in this report.
  3334.  
  3335. \(load 'summary.lsp)
  3336.  
  3337. \(fg) 
  3338.  
  3339. \(ce)Appendix B. An Overview of Kyoto Common Lisp
  3340. \(set-page pp-overview)
  3341. \(fr)
  3342. \(fi)Kyoto Common Lisp\(fr) (KCL for short) is a full implementation of the
  3343. Common
  3344. Lisp language.  KCL is a highly portable Common Lisp system intended for
  3345. several classes of machines, from mini/micro to mainframe.  The key idea
  3346. behind the portability is the use of the C language and its standard libraries
  3347. as the interface with
  3348. the underlying machines and operating systems:  The kernel of the system
  3349. is written in C and the rest of the system is written in Common
  3350. Lisp.  Even the compiler generates intermediate code in C.  KCL is also
  3351. an efficient and compact system:  KCL regards the runtime efficiency of
  3352. interpreted code as important as the efficiency of compiled code.  The small
  3353. size of the KCL system makes KCL suitable for the current computer technology,
  3354. such as the use of virtual memory and cache memory.  This document reports
  3355. the current status of KCL, its
  3356. implementation, and system performance.  This document is a draft:
  3357. the description is still incomplete and informal,
  3358. and some technical terms are used without
  3359. definition or explanation.  A full paper on the KCL implementation is in
  3360. preparation.
  3361.  
  3362.  
  3363. \(reserve 5)\(fg)
  3364. KCL is a full Common Lisp system.
  3365. \(fr)
  3366. KCL is a full implementation of the Common Lisp language described in
  3367. the \(fi)Common Lisp Reference Manual\(fr):
  3368.  
  3369.  
  3370. \(ce)\(fi)Common Lisp: The Language\(fr).
  3371. \(ce)by Guy L. Steele et al.
  3372. \(ce)Digital Press, 1984
  3373.  
  3374. KCL supports all Common Lisp functions, macros, and special forms defined
  3375. in the \(fi)Common Lisp Reference Manual\(fr).  All Common Lisp variables
  3376. and constants are defined in KCL exactly as
  3377. described in the \(fi)Common Lisp Reference Manual\(fr).
  3378.  
  3379.  
  3380. \(reserve 5)\(fg)
  3381. KCL is available on several machines already.
  3382. \(fr)
  3383. Currently, there are four major versions of KCL:
  3384.  
  3385.     1. KCL/AOS
  3386.        Machine: \(sm)Data General's Eclipse MV series super-minicomputers (MV10000, MV8000, MV6000, and MV4000)\(rm)
  3387.        Operating System: \(sm)Data General's original AOS/VS (Advanced Operating System / Virtual Storage)\(rm)
  3388.  
  3389.     2. KCL/VAX
  3390.        Machine: \(sm)Digital Equipment Corporation's VAX 11 series machines (VAX 11/780 and VAX 11/750)\(rm)
  3391.        Operating System: UNIX 4.2 bsd
  3392.  
  3393.     3. KCL/SUN
  3394.        Machine: \(sm)Sun Microsystems' Sun Workstation (MC68000 base)\(rm)
  3395.        Operating System: UNIX 4.2 bsd
  3396.  
  3397.     4. KCL/UST
  3398.        Machine: \(sm)Sumitomo Electric Industries and Digital Computer Laboratory's personal workstation Ustation E15 (MC68000 base)\(rm)
  3399.        Operating System: UNIX V (Uniplus' version)
  3400.  
  3401. KCL/AOS is the original version of KCL, which was developed
  3402. at Research Institute for Mathematical Sciences (RIMS), Kyoto University,
  3403. with the cooperation of Nippon Data General Corporation.  Other versions are
  3404. ported from KCL/AOS at RIMS.  All four versions share most of the source
  3405. files of KCL.  Improvements and error corrections are performed on
  3406. the common source files, and the most recent revisions are brought to each
  3407. machine from time to time.
  3408.  
  3409. Ports to other machines
  3410. and other operating systems are being undertaken or in preparation
  3411. at other organizations.  KCL is expected to become available on the following
  3412. machines in the near future.
  3413.  
  3414.     * IBM (and IBM-compatible) M series machines
  3415.     * Apollo Domain
  3416.     * Perkins Elmer
  3417.     * VAX 11 (running VMS)
  3418.     * VAX 11 (running Eunice, the Unix emulator)
  3419.     * Eclipse MV (running DGUX, Data General's native Unix)
  3420.  
  3421.  
  3422. \(reserve 5)\(fg)
  3423. KCL is written in C and Lisp
  3424. \(fr)
  3425. The kernel of KCL is written in C, including:
  3426.  
  3427.     * memory management and garbage collection
  3428.     * the evaluator (or interpreter)
  3429.     * Common Lisp special forms
  3430.  
  3431. The KCL compiler is entirely written in Common Lisp.
  3432.  
  3433. Each Common Lisp function or macro is written either in C or in Lisp.
  3434. \(reserve 3)
  3435.     in C:
  3436.         418 Common Lisp functions
  3437.         11 Common Lisp macros
  3438. \(reserve 3)
  3439.     in Lisp:
  3440.         133 Common Lisp functions
  3441.         59 Common Lisp macros
  3442.  
  3443. The size of the source code is:
  3444. \(reserve 6)
  3445.     C code         705 Kbytes
  3446.     Common Lisp functions and macros written in Lisp
  3447.              173 Kbytes
  3448.     The compiler     264 Kbytes
  3449.     \(fs)-------------------------\(fr)
  3450.         total    1142 Kbytes
  3451.  
  3452. Three routines in the kernel are partly written
  3453. in assembly language.  These routines are:
  3454.  
  3455.     * bignum multiplication
  3456.     * bignum division
  3457.     * \(sm)bit table manipulation of the garbage collector\(rm)
  3458.  
  3459. The total size of assembly code is 20 to 30 lines, depending on the
  3460. version of KCL.
  3461.  
  3462.  
  3463. \(reserve 5)\(fg)
  3464. KCL/AOS is built up by old-fashioned bootstrapping
  3465. \(fr)
  3466. When KCL/AOS, the original version of KCL, was born, the following steps
  3467. were taken to build it up.
  3468.  
  3469.     1. \(sm)Compile all C code with the C compiler and link them
  3470. all.  A subset of KCL is ready to run at this moment.\(rm)
  3471.  
  3472.     2. \(sm)Load all Lisp code into KCL.  Now the full system is ready
  3473. to run, although the compiler and some Common Lisp functions and macros
  3474. run interpretively.\(rm)
  3475.  
  3476.     3. \(sm)Compile the source files of the KCL compiler
  3477. with the (interpreted) KCL compiler itself.  Load each Fasl-file (i.e., the
  3478. file created by the KCL compiler) immediately
  3479. after it is generated.  The compilation process becomes faster
  3480. toward the end of this step.  Finally, the whole KCL compiler is ready
  3481. to run by itself.\(rm)
  3482.  
  3483.     4. \(sm)Compile the Common Lisp functions and macros written in Lisp,
  3484. with the compiled KCL compiler.  Load the Fasl-files.  This completes
  3485. the generation of the full system.\(rm)
  3486.  
  3487. The same steps are taken whenever drastic changes are made
  3488. to the kernel.  On the other hand, the procedure to port KCL or to
  3489. revise the ported versions of KCL is much simpler, because all Lisp code has
  3490. been cross-compiled by the compiler of KCL/AOS beforehand.
  3491.  
  3492.  
  3493. \(reserve 5)\(fg)
  3494. Objects are represented by cells.
  3495. \(fr)
  3496. KCL does not support the so-called immediate data.  Any KCL object is
  3497. represented as (a pointer to) a cell that is allocated on the heap.  Each
  3498. cell consists of several words (1 word = 32 bit) whose first word is in the
  3499. format common to all data types: half of the word
  3500. is the type indicator and the other half
  3501. is used as the mark by the garbage collector.  For instance, a cons cell
  3502. consists of three words:
  3503. \(reserve 7)\(fp)
  3504.         \(fs)1----------2-----------3\(fp)
  3505.         |  'CONS'  |  mark-bit \(fs)|
  3506.         \(fs)4----------8-----------6\(fp)
  3507.         |      car-pointer     \(fs)|
  3508.         \(fs)4----------------------6\(fp)
  3509.         |      cdr-pointer     \(fs)|
  3510.         \(fs)7----------------------9\(fp)
  3511. \(fr)
  3512. and a fixnum cell consists of two words:
  3513. \(reserve 5)\(fp)
  3514.         \(fs)1----------2-----------3\(fp)
  3515.         | 'FIXNUM' |  mark-bit \(fs)|
  3516.         \(fs)4----------8-----------6\(fp)
  3517.         |    fixnum-value      \(fs)|
  3518.         \(fs)7----------------------9\(fp)
  3519. \(fr)
  3520. Array headers and compiled-function headers are represented in this way, and
  3521. array elements and compiled code are placed elsewhere.
  3522.  
  3523. Internally in compiled functions, certain Lisp objects
  3524. may be represented simply by their values.  For example, a fixnum object
  3525. may be represented by its fixnum value, and a character object
  3526. may be represented by its character code.
  3527.  
  3528. Cells of small fixnums ranging from \(fp)-1024\(fr) to \(fp)1023\(fr) and
  3529. cells of characters
  3530. are pre-allocated in fixed locations.  Thus, for example,
  3531. \(fp)
  3532.     (eq 1023 1023)
  3533. \(fr)
  3534. yields \(fp)t\(fr), whereas
  3535. \(fp)
  3536.     (eq 1024 1024)
  3537. \(fr)
  3538. yields \(fp)nil\(fr).
  3539.  
  3540.  
  3541. \(reserve 5)\(fg)
  3542. The heap is divided into pages.
  3543. \(fr)
  3544. The whole heap of KCL is divided into pages (1 page = 2048 bytes).  Each page
  3545. falls in one of the following classes:
  3546.  
  3547.     * pages that contain cells consisting of the same number of words
  3548.     * pages that contain binary data such as compiled function code
  3549.     * pages that contain relocatable data such as array elements
  3550.  
  3551. Free cells (i.e., those cells that are not used any more) consisting of the
  3552. same number of words are linked together to form a free list.  When a new
  3553. cell is requested, the first cell in the free list (if it is not empty)
  3554. is used and is removed from the list.  If the free list is empty, then the
  3555. garbage collector begins to run to collect unused cells.  If the new
  3556. free list is too short after the garbage collection,
  3557. then new pages are allocated dynamically.  Free
  3558. binary data are also linked together in the order of the size
  3559. so that, when a binary datum is being allocated on the heap, the smallest
  3560. free area that is large enough to hold the binary datum
  3561. will be used.  Cell pages are never compactified.  Once a page
  3562. is allocated for cells with
  3563. \(fi)n\(fr) words, the page is used for cells with \(fi)n\(fr) words only,
  3564. even after all the cells in the page become garbage.  The same rule holds for
  3565. binary pages.  In contrast, relocatable pages are sometimes
  3566. compactified.  That is, each relocatable datum may be moved to another place.
  3567.  
  3568. The actual configuration of the KCL heap is:
  3569. \(reserve 4)\(fp)
  3570.   lower address                                             higher address
  3571.     \(fs)1-------------------------------2--------2---------------------3\(fp)
  3572.     |  cell pages and binary pages  |  hole  |  relocatable pages  \(fs)|
  3573.     \(fs)7-------------------------------8--------8---------------------9\(fp)
  3574. \(fr)
  3575. There is a "hole" between the area for cell/binary pages and the area for
  3576. relocatable pages.  New pages are allocated in the hole for cell/binary pages,
  3577. whereas new relocatable pages are allocated by expanding the
  3578. heap to the higher address, i.e., to the right in the this figure.  When
  3579. the hole becomes empty, the area for relocatable pages are shifted to the
  3580. right to reserve a certain number of pages as the hole.  During this process,
  3581. the relocatable data in the relocatable pages are compactified.  No free
  3582. list is maintained for relocatable data.
  3583.  
  3584. Symbol print names and string bodies are usually allocated in relocatable
  3585. pages.  However, when the KCL system is created, i.e., when the object module
  3586. of KCL is created, such relocatable data are moved towards the area for
  3587. cell/binary pages and then the pages for relocatable data are
  3588. marked "static".  The garbage collector never tries to sweep static
  3589. pages.  Thus, within the object module of KCL, the heap looks:
  3590. \(reserve 4)\(fp)
  3591.   lower address                        higher address
  3592.     \(fs)1--------------------------------------3\(fp)
  3593.     |  cell/binary pages and static pages  \(fs)|
  3594.     \(fs)7--------------------------------------9\(fp)
  3595. \(fr)
  3596. Notice that the hole is not included in the object module; it is allocated
  3597. only when the KCL system is started.  This saves the secondary storage
  3598. a little bit.  The maximum size of the hole is about
  3599. 100 pages (= 200 Kbytes).
  3600.  
  3601.  
  3602. \(reserve 5)\(fg)
  3603. KCL uses five stacks.
  3604. \(fr)
  3605. KCL uses the following stacks.
  3606.  
  3607.     * Value Stack, for
  3608.          arguments/values passing
  3609.          lexical variables allocation
  3610.          temporary values saving
  3611.  
  3612.     * Frame Stack, consisting of
  3613.          catch, block, tagbody frames
  3614.  
  3615.     * Bind Stack, for
  3616.          shallow binding of dynamic variables
  3617.  
  3618.     * Invocation History Stack, maintaining
  3619.          information for debugging
  3620.  
  3621.     * C Language Control Stack, sometimes used in compiled functions for:
  3622.          arguments/values passing
  3623.          typed lexical variables allocation
  3624.          temporary values saving,
  3625.       in addition to the obvious use such as function invocation
  3626.  
  3627.  
  3628. \(reserve 5)\(fg)
  3629. Arguments/values are passed via the value stack.
  3630. \(fr)
  3631. To show the argument/value passing mechanism, here we list the actual code
  3632. for the Common Lisp function \(fp)cons\(fr).
  3633. \(reserve 10)\(fp)
  3634.     Lcons()
  3635.     {
  3636.         object x;
  3637.         check_arg(2);
  3638.         x = alloc_object(t_cons);
  3639.         x->c.c_car = vs_base[0];
  3640.         x->c.c_cdr = vs_base[1];
  3641.         vs_base[0] = x;
  3642.         vs_pop;
  3643.     }
  3644. \(fr)
  3645. We adopted the convention that the name of a function
  3646. that implements a Common Lisp function begins with '\(fp)L\(fr)', followed
  3647. by the name of the Common Lisp function.  (Strictly speaking,
  3648. '\(fp)-\(fr)' and '\(fp)*\(fr)' in the Common Lisp function name are replaced
  3649. by '\(fp)_\(fr)' and '\(fp)A\(fr)', respectively,
  3650. to obey the syntax of C.)  Arguments to
  3651. functions are pushed on the value stack.  The stack pointer
  3652. \(fp)vs_base\(fr) (value stack base) points to the first argument and
  3653. another pointer \(fp)vs_top\(fr) points to the stack location next to the
  3654. last argument.  Thus, for example, when \(fp)cons\(fr) is called
  3655. with the first argument \(fp)1\(fr) and the second argument \(fp)2\(fr), 
  3656. the value stack looks:
  3657. \(reserve 12)\(fp)
  3658.               \(fs)4---------6\(fp)
  3659.      vs_top \(fs)->\(fp)|         \(fs)|
  3660.               \(fs)4---------6\(fp)
  3661.               |    2    \(fs)|
  3662.               \(fs)4---------6\(fp)
  3663.     vs_base \(fs)->\(fp)|    1    \(fs)|
  3664.               \(fs)4---------6\(fp)
  3665.               |         |
  3666.               :         :
  3667.               |         \(fs)|
  3668.       \(fp)bottom  \(fs)7---------9\(fp)
  3669.                   value stack
  3670. \(fr)
  3671. \(fp)check_arg(2)\(fr) in the code of \(fp)Lcons\(fr) checks if exactly
  3672. two arguments are supplied to \(fp)cons\(fr).  That is, it checks whether
  3673. the difference of \(fp)vs_top\(fr) and \(fp)vs_base\(fr) is \(fp)2\(fr), and
  3674. if not, it causes an error.  \(fp)allocate_object(t_cons)\(fr) allocates a
  3675. cons cell in the heap and returns the pointer to the cell.  After the
  3676. \(fp)car\(fr) and the \(fp)cdr\(fr) fields of the cell are set,
  3677. the cell pointer is put onto the value
  3678. stack.  The two stack pointers are used also on return from a function
  3679. call.  \(fp)vs_base\(fr) points to the first returned value
  3680. and \(fp)vs_top\(fr) points to the stack location next
  3681. to the last returned value.  \(fp)vs_pop\(fr)
  3682. in the code above decrements \(fp)vs_top\(fr) by one.
  3683. \(reserve 12)\(fp)
  3684.               \(fs)4---------6\(fp)
  3685.               |         \(fs)|
  3686.               \(fs)4---------6\(fp)
  3687.      vs_top \(fs)->\(fp)|         \(fs)|
  3688.               \(fs)4---------6\(fp)
  3689.     vs_base \(fs)->\(fp)| (1 . 2) \(fs)|
  3690.               \(fs)4---------6\(fp)
  3691.               |         |
  3692.               :         :
  3693.               |         \(fs)|
  3694.       \(fp)bottom  \(fs)7---------9\(fp)
  3695.                   value stack
  3696. \(fr)
  3697. Because the same stack pointers are used both for argument passing and
  3698. for return value passing, the Common Lisp function \(fp)values\(fr) does
  3699. almost nothing.
  3700. \(reserve 16)\(fp)
  3701.     On the call of (values 1 2)    On return from (values 1 2)
  3702.  
  3703.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3704.      vs_top \(fs)->\(fp)|         |       vs_top \(fs)->\(fp)|         \(fs)|
  3705.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3706.               |    2    |                |    2    \(fs)|
  3707.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3708.     vs_base \(fs)->\(fp)|    1    |      vs_base \(fs)->\(fp)|    1    \(fs)|
  3709.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3710.               |         |                |         |
  3711.               :         :                :         :
  3712.               |         |                |         \(fs)|
  3713.       \(fp)bottom  \(fs)7---------9\(fp)        bottom  \(fs)7---------9\(fp)
  3714.                   value stack                 value stack
  3715. \(fr)
  3716. In most cases, the caller of a function uses only the first returned value
  3717. which is pointed to by \(fp)vs_base\(fr).  This is not the case, however, when
  3718. the called function returns no value at all.  In order to avoid the check
  3719. whether this is the case, each KCL function, on return from its call,
  3720. sets \(fp)nil\(fr) to the stack entry which is pointed to
  3721. by \(fp)vs_base\(fr), whenever it returns no value at all.  Thus, for
  3722. instance, the actual code for the Common Lisp function \(fp)values\(fr) is:
  3723. \(reserve 4)\(fp)
  3724.     Lvalues()
  3725.     {
  3726.         vs_top[0] = Cnil;
  3727.     }
  3728. \(fr)
  3729. where \(fp)Cnil\(fr) is a global variable that always contains the pointer to
  3730. \(fp)nil\(fr).  See why this works.
  3731.  
  3732.  
  3733. \(reserve 5)\(fg)
  3734. The interpreter uses A-lists.
  3735. \(fr)
  3736. The KCL interpreter uses three A-lists (Association lists) to represent
  3737. lexical environment.
  3738.  
  3739.     * One for variable bindings
  3740.     * One for local function/macro definitions
  3741.     * One for tag/block bindings
  3742.  
  3743. When a function closure is created, the current three A-lists are
  3744. saved in the closure along with the lambda expression.  Later, when the
  3745. closure is invoked, the saved A-lists are
  3746. used to recover the lexical environment.
  3747.  
  3748.  
  3749. \(reserve 5)\(fg)
  3750. The invocation history stack is used for debugging.
  3751. \(fr)
  3752. The invocation history stack consists of two kinds of elements.  Each element
  3753. may be either a pair of a Lisp form and a pointer to lexical environment:
  3754. \(reserve 3)\(fp)
  3755.     \(fs)1---------------------2---------------------3\(fp)
  3756.     |        form         | environment-pointer \(fs)|
  3757.     \(fs)7---------------------8---------------------9\(fp)
  3758. \(fr)
  3759. or a pair of a function name and a pointer to the value stack:
  3760. \(reserve 3)\(fp)
  3761.     \(fs)1---------------------2---------------------3\(fp)
  3762.     |    function-name    | value-stack-pointer \(fs)|
  3763.     \(fs)7---------------------8---------------------9\(fp)
  3764. \(fr)
  3765. The former is pushed on the invocation history stack
  3766. when an interpreted code is evaluated.  The \(fi)form\(fr)
  3767. is the interpreted code itself and the \(fi)environment-pointer\(fr) points to
  3768. the three consecutive memory words each of which holds the A-list that
  3769. represents the lexical environment.  The latter is pushed
  3770. when a compiled function is invoked.  The \(fi)function-name\(fr)
  3771. is the name of the called function and the \(fi)value-stack-pointer\(fr)
  3772. points to the
  3773. value stack location which is pointed to by \(fp)vs_base\(fr)
  3774. when the function is called.  For both kinds, the element on the invocation
  3775. history stack is poped at the end of the evaluation.
  3776.  
  3777. Let us see how the invocation history stack is used for debugging.
  3778. \(fp)
  3779.     >(defun fact (x)        ;;; \(fr)Wrong definition of the\(fp)
  3780.        (if (= x 0)            ;;; \(fr)factorial function.\(fp)
  3781.            one            ;;; one\(fr) should be \(fp)1\(fr).\(fp)
  3782.            (* x (fact (1- x)))))
  3783.     fact
  3784.     
  3785.     >(fact 3)            ;;; \(fr)Tries \(fp)3!
  3786.     
  3787.     Error: The variable ONE is unbound.
  3788.     Error signalled by IF.
  3789.     
  3790.     Broken at IF.
  3791.     >>:b                ;;; \(fr)Backtrace.\(fp)
  3792.     Backtrace: eval > fact > if > fact > if > fact > if > fact > IF
  3793.                     ;;; \(fr)Currently at the last \(fp)if.
  3794.     >>:h                ;;; \(fr)Help.\(fp)
  3795.  
  3796.     :c(urrent)    Show current function.
  3797.     :p(revious)    Move to previous function.
  3798.     :n(ext)        Move to next function.
  3799.     :b(acktrace)    Backtrace.
  3800.     :h(elp)        Help.
  3801.     :q(uit)        Return to top-level.
  3802.     :r(esume)    Return to the caller
  3803.     :l(ocal)    Show n-th local value.
  3804.     :v(ariables)    Show local variables.
  3805.     :functions    Show local functions.
  3806.     :blocks        Show block names.
  3807.     :tags        Show tags.
  3808.     :hide        Hide a function
  3809.     :hide-package    Hide a package.
  3810.     :unhide        Unhide a function
  3811.     :unhide-package    Unhide a package.
  3812.  
  3813.     >>:p                ;;; \(fr)Move to the last call of \(fp)fact.
  3814.     Broken at FACT.
  3815.     
  3816.     >>:b
  3817.     Backtrace: eval > fact > if > fact > if > fact > if > FACT > if
  3818.                     ;;; \(fr)Now at the last \(fp)fact.
  3819.     >>:v                ;;; \(fr)The environment at the last call\(fp)
  3820.     Local variables: x.        ;;; \(fr)to \(fp)fact\(fr) is recovered.\(fp)
  3821.                     ;;; x \(fr)is the only bound variable.\(fp)
  3822.     >>x
  3823.     0                ;;; \(fr)The value of \(fp)x\(fr) is \(fp)0.
  3824.     
  3825.     >>:blocks
  3826.     Block names: fact.        ;;; \(fr)The block \(fp)fact\(fr) is established.\(fp)
  3827.     
  3828.     >>(return-from fact 1)        ;;; \(fr)Return from the last call of\(fp)
  3829.     6                ;;; fact \(fr)with the value of \(fp)0.
  3830.                     ;;; \(fr)The execution is resumed and\(fp)
  3831.     >                ;;; \(fr)the value \(fp)6\(fr) is returned.\(fp)
  3832.                     ;;; \(fr)Again at the top-level loop.\(fp)
  3833. \(fr)
  3834.  
  3835.  
  3836. \(reserve 5)\(fg)
  3837. The KCL compiler generates intermediate code in C.
  3838. \(fr)
  3839. The KCL compiler is essentially a translator from Common Lisp to C.  Given
  3840. a Lisp source file, the compiler first generates three intermediate files:
  3841.  
  3842.     * a C-file which consists of the C version of the Lisp program
  3843.     * an H-file which consists of declarations referenced in the C-file
  3844.     * a Data-file which consists of Lisp data to be used at load time
  3845.  
  3846. The KCL compiler then invokes the C compiler to compile the C-file into
  3847. an object file.  Finally, the contents of the Data-file is appended to
  3848. the object file to make a \(fi)Fasl-file\(fr).  The generated Fasl-file can
  3849. be loaded into the KCL system by the Common Lisp
  3850. function \(fp)load\(fr).  By default, the three intermediate files
  3851. are deleted after the compilation, but, if asked, the compiler
  3852. leaves them.
  3853.  
  3854. The merits of the use of C as the intermediate language are:
  3855.  
  3856.     * \(sm)The KCL compiler is highly portable.  Indeed the four versions
  3857. of KCL share the same compiler.  Only the calling sequence
  3858. of the C compiler and the handling of the intermediate files are different
  3859. in these versions.\(rm)
  3860.  
  3861.     * \(sm)Cross compilation is possible, because the contents
  3862. of the intermediate files are common to all versions of KCL.  For example,
  3863. one can compile his or her Lisp program by the KCL compiler on Eclipse,
  3864. bring the intermediate files to SUN, compile the C-file with the C compiler
  3865. on SUN, and then append the Data-file
  3866. to the object file.  This procedure generates the Fasl-file for
  3867. the KCL system on SUN.  This kind of cross compilation makes it easier to
  3868. port KCL.\(rm)
  3869.  
  3870.     * \(sm)Hardware-dependent optimizations such as register allocations
  3871. are done by the C compiler.\(rm)
  3872.  
  3873. The demerits are:
  3874.  
  3875.     * \(sm)At those sites where no C compiler is available,
  3876. the users cannot compile their Lisp programs.\(rm)
  3877.  
  3878.     * \(sm)The compilation time takes long.  70% to 80%
  3879. of the compilation time is used by the C compiler.  The KCL compiler is
  3880. perhaps the slowest compiler in the Lisp world.\(rm)
  3881.  
  3882.  
  3883. \(reserve 5)\(fg)
  3884. The compiler mimics human C programmer.
  3885. \(fr)
  3886. The format of the intermediate C code generated by the KCL compiler is the
  3887. same as the hand-coded C code of the KCL source programs.  For example,
  3888. supposing that the Lisp source file contains the
  3889. following function definition:
  3890. \(fp)
  3891.     (defun add1 (x) (1+ x))
  3892. \(fr)
  3893. The compiler generates the following intermediate C code.
  3894. \(reserve 21)\(fp)
  3895.     init_code(start,size,data)char *start;int size;object data;
  3896.     {    register object *base=vs_top;
  3897.         register object *sup=base+VM2;
  3898.         vs_check;
  3899.         Cstart=start;Csize=size;Cdata=data;
  3900.         set_VV(VV,VM1,data);
  3901.         MF(VV[0],L1,start,size,data);
  3902.         vs_top=vs_base=base;
  3903.     }
  3904.     /*    function definition for ADD1    */
  3905.     
  3906.     static L1()
  3907.     {    register object *base=vs_base;
  3908.         register object *sup=base+VM3;
  3909.         vs_reserve(VM3);
  3910.         check_arg(1);
  3911.         vs_top=sup;
  3912.         base[1]=one_plus(base[0]);
  3913.         vs_top=(vs_base=base+1)+1;
  3914.         return;
  3915.     }
  3916. \(fr)
  3917. The C function \(fp)L1\(fr) implements the Lisp
  3918. function \(fp)add1\(fr).  This relation is established by \(fp)MF\(fr) in
  3919. the initialization function \(fp)init_code\(fr), which is invoked at
  3920. load time.  There,
  3921. the vector \(fp)VV\(fr) consists of Lisp objects; \(fp)VV[0]\(fr) in this
  3922. example
  3923. holds the Lisp symbol \(fp)add1\(fr).  \(fp)VM3\(fr) in the definition
  3924. of \(fp)L1\(fr) is a C macro declared in the corresponding H-file.  The actual
  3925. value of \(fp)VM3\(fr) is the number of value stack locations used
  3926. by \(fp)L1\(fr), i.e., \(fp)2\(fr) in this example.  Thus the following
  3927. macro definition is found in the H-file.
  3928. \(fp)
  3929.     #define VM3 2
  3930. \(fr)
  3931. When the compiled \(fp)add1\(fr) is called, the value stack looks:
  3932. \(reserve 14)\(fp)
  3933.     On the call of (add1 1)    On return from (add1 1)
  3934.  
  3935.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3936.               |         |       vs_top \(fs)->\(fp)|         \(fs)|
  3937.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3938.      vs_top \(fs)->\(fp)|         |      vs_base \(fs)->\(fp)|    2    \(fs)|
  3939.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3940.     vs_base \(fs)->\(fp)|    1    |                |    1    \(fs)|
  3941.               \(fs)4---------6\(fp)                \(fs)4---------6\(fp)
  3942.               |         |                |         |
  3943.               :         :                :         :
  3944.               |         |                |         \(fs)|
  3945.       \(fp)bottom  \(fs)7---------9\(fp)        bottom  \(fs)7---------9\(fp)
  3946.                   value stack                 value stack
  3947. \(fr)
  3948. Note that the two value stack pointers need not be moved
  3949. in this example.  This shows that the KCL compiler still has room
  3950. for improvement.
  3951.  
  3952.  
  3953. \(reserve 5)\(fg)
  3954. Lexical environment of compiled closures is represented by a list.
  3955. \(fr)
  3956. The KCL compiler takes two passes before it invokes the C compiler.  The
  3957. major role of the first pass is to detect function closures and to detect, for
  3958. each function closure, those lexical objects (i.e., lexical variable, local
  3959. function definitions, tas, and block-names) to be enclosed within
  3960. the closure.  This check must be done before the C code generation in the
  3961. second pass, because lexical objects to be enclosed in function closures
  3962. are treated in a different way from those not enclosed.
  3963.  
  3964. Ordinarily, lexical variables in a compiled function \(fi)f\(fr)
  3965. are allocated on the value stack.  However, if a lexical variable
  3966. is to be enclosed in function closures, it is allocated on a list,
  3967. called "environment list", which is local to \(fi)f\(fr).  In addition,
  3968. one entity is
  3969. reserved on the value stack,
  3970. in which the pointer to the variable's location (within the environment list)
  3971. is stored, so that the variable may be accessed by indexing
  3972. rather than by list traversal.  The environment list is
  3973. a pushdown list:  It is empty when \(fi)f\(fr) is called.  An
  3974. element is pushed on the environment list
  3975. when a variable to be enclosed in closures is bound, and is poped
  3976. when the binding is no more in effect.  That is, at any moment during
  3977. execution of \(fi)f\(fr), the environment list contains
  3978. those lexical variables whose
  3979. binding is still in effect and which should be enclosed in closures.  When
  3980. a compiled closure is created during execution of \(fi)f\(fr), 
  3981. the compiled code for the closure is coupled with the environment list at that
  3982. moment to form the compiled closure.  Later, when the compiled closure is
  3983. invoked, as many entities as the elements in the environment list is
  3984. reserved on the value stack, each of which points to a lexical object in the
  3985. environment list, so that, again, each object may be referenced by indexing.
  3986.  
  3987. Let us see an example.  Suppose the following function has been compiled.
  3988. \(fp)
  3989.     (defun foo (x)
  3990.       (let ((a #'(lambda () (incf x)))
  3991.             (y x))
  3992.         (values a #'(lambda () (incf x y)))))
  3993. \(fr)
  3994. \(fp)foo\(fr) returns two compiled closures.  The first closure increments
  3995. \(fp)x\(fr) by one, whereas the second closure increments \(fp)x\(fr)
  3996. by the initial value of \(fp)x\(fr).  Both closures return the incremented
  3997. value of \(fp)x\(fr).
  3998. \(fp)
  3999.     >(multiple-value-setq (f g) (foo 10))
  4000.     #<compiled-closure nil>
  4001.  
  4002.     >(funcall f)
  4003.     11
  4004.  
  4005.     >(funcall g)
  4006.     21
  4007.  
  4008.     >
  4009. \(fr)
  4010. After this, the two compiled closures look:
  4011. \(reserve 12)\(fp)
  4012.     second closure        y:                    x:
  4013.     \(fs)1-------2------3\(fp)      \(fs)1-------2------3\(fp)      \(fs)1------2------3\(fp)
  4014.     |  **   |    \(fs)--5----->\(fp)|  10   |    \(fs)--5----->\(fp)|  21  | nil  \(fs)|
  4015.     \(fs)7-------8------9\(fp)      \(fs)7-------8------9\(fp)      \(fs)7------8------9\(fp)
  4016.                                                     \(fs)^\(fp)
  4017.                           first closure             \(fs)|
  4018.                           \(fs)1-------2------3\(fp)          \(fs)|
  4019.                           \(fp)|   *   |    \(fs)--5----------9\(fp)
  4020.                           \(fs)7-------8------9\(fp)
  4021.  
  4022.    * : \(fr)address of the compiled code for \(fp)#'(lambda () (incf x))
  4023.   ** : \(fr)address of the compiled code for \(fp)#'(lambda () (incf x y))
  4024. \(fr)
  4025.  
  4026.  
  4027. \(reserve 5)\(fg)
  4028. Declarations increase code efficiency.
  4029. \(fr)
  4030. Declarations, especially \(fp)type\(fr) and \(fp)function\(fr) declarations,
  4031. increase the efficiency of the compiled code.  For example, for the
  4032. following Lisp source file, with two Common Lisp declarations added,
  4033. \(reserve 10)\(fp)
  4034.     (eval-when (compile)
  4035.       (proclaim '(function tak (fixnum fixnum fixnum) fixnum)))
  4036.  
  4037.     (defun tak (x y z)
  4038.       (declare (fixnum x y z))
  4039.       (if (not (< y x))
  4040.           z
  4041.           (tak (tak (1- x) y z)
  4042.                (tak (1- y) z x)
  4043.                (tak (1- z) x y))))
  4044. \(fr)
  4045. the compiler generates the following C code.
  4046. \(reserve 20)\(fp)
  4047.     /*  local entry for function TAK  */
  4048.     static int LI2(V4,V5,V6)
  4049.     int V4,V5,V6;
  4050.     {    VMB3 VMS3 VMV3
  4051.         if((V5)<(V4)){
  4052.         goto T4;}
  4053.         VMR3(V6)
  4054.     T4:;
  4055.         {int V7=LI2((V4)-1,V5,V6);
  4056.         {int V8=LI2((V5)-1,V6,V4);
  4057.         VMR3(LI2(V7,V8,LI2((V6)-1,V4,V5)))}}
  4058.     }
  4059.     /*  global entry for the function TAK  */
  4060.     static L2()
  4061.     {    register object *base=vs_base;
  4062.         base[0]=make_fixnum(LI2(fix(base[0]),
  4063.                                 fix(base[1]),
  4064.                                 fix(base[2])));
  4065.         vs_base=base; vs_top=base+1;
  4066.     }
  4067. \(fr)
  4068. The main part of the \(fp)tak\(fr) function is \(fp)LI2\(fr).  If
  4069. redundant parentheses are removed, macros are expanded, and
  4070. identifiers are renamed, we obtain the following code equivalent
  4071. to \(fp)LI2\(fr).
  4072. \(reserve 12)\(fp)
  4073.     /*  local entry for function TAK  */
  4074.     static int tak(x,y,z)
  4075.     int x,y,z;
  4076.     {
  4077.         if(y<x) goto L;
  4078.         return(z);
  4079.     L:
  4080.         {    int t1=tak(x-1,y,z);
  4081.                 int t2=tak(y-1,z,x);
  4082.                 return(tak(t1,t2,tak(z-1,x,y)));
  4083.         }
  4084.     }
  4085. \(fr)
  4086. This is almost hand-written \(fp)tak\(fr) code in C.  The only overhead is
  4087. the use of the temporary variables \(fp)t1\(fr) and \(fp)t2\(fr).  This is
  4088. necessary to make sure that the arguments are evaluated
  4089. in the correct order (i.e., from left to right), since the
  4090. C language does not specify the order of argument evaluation.  If the
  4091. compiler generated the following code,
  4092. \(fp)
  4093.     return(tak(tak(x-1,y,z),tak(y-1,z,x),tak(z-1,x,y)));
  4094. \(fr)
  4095. the C compiler of Eclipse AOS/VS evaluates the three inner calls
  4096. to \(fp)tak\(fr) from left to right (this is all right),
  4097. whereas the C compiler of Unix evaluates from
  4098. right to left (this is bad).  In this example of \(fp)tak\(fr),
  4099. the order of evaluation
  4100. does not matter actually, because \(fp)tak\(fr) causes no side effects.  But
  4101. the KCL compiler does not know that.  The KCL compiler still has room
  4102. for improvements.
  4103.  
  4104.  
  4105. \(reserve 5)\(fg)
  4106. KCL does not have "disassembler".
  4107. \(fr)
  4108. Common Lisp defines a function \(fp)disassemble\(fr), which is supposed to
  4109. disassemble a compiled function and
  4110. to display the assembler code.  According to the \(fi)Common Lisp
  4111. Reference Manual\(fr),
  4112. \(fi)
  4113.     This is primary useful for debugging the compiler, ..
  4114. \(fr)
  4115. This is, however, \(fi)useless\(fr) in our case, because we are not concerned
  4116. with assembly language.  Rather, we are interested in the C code generated by
  4117. the KCL compiler.  Thus the \(fp)disassemble\(fr) function in KCL accepts
  4118. not-yet-compiled functions only and displays the translated C code.
  4119. \(fp)
  4120.     >(defun add1 (x) (1+ x))
  4121.     add1
  4122.     
  4123.     >(disassemble 'add1)
  4124.     init_code(start,size,data)char *start;int size;object data;
  4125.     {    register object *base=vs_top;
  4126.         register object *sup=base+VM2;
  4127.         vs_check;
  4128.         Cstart=start;Csize=size;Cdata=data;set_VV(VV,VM1,data);
  4129.         MF(VV[0],L1,start,size,data);
  4130.         vs_top=vs_base=base;
  4131.     }
  4132.     /*    function definition for ADD1    */
  4133.     
  4134.     static L1()
  4135.     {    register object *base=vs_base;
  4136.         register object *sup=base+VM3;
  4137.         vs_check;
  4138.         vs_top=sup;
  4139.         base[1]=one_plus(base[0]);
  4140.         vs_top=(vs_base=base+1)+1;
  4141.         return;
  4142.     }
  4143.     
  4144.     >
  4145. \(fr)
  4146.  
  4147.  
  4148. \(reserve 5)\(fg)
  4149. KCL/AOS has its own screen editor.
  4150. \(fr)
  4151. KCL/AOS has an embedded full-screen editor which resembles EMACS.  The editor
  4152. is called FeCl2 as the acronym of Full-screen Editor as a Common Lisp
  4153. TOOl.  It is invoked by the Common Lisp function \(fp)ed\(fr).  Unfortunately,
  4154. FeCl2 is not supported by other versions of KCL, simply because we are
  4155. too lazy to port it (it is written in C).  For these versions, \(fp)ed\(fr)
  4156. invokes the \(fp)vi\(fr) editor of Unix.
  4157.  
  4158.  
  4159. \(reserve 5)\(fg)
  4160. KCL has C language interface.
  4161. \(fr)
  4162. The user can embed his or her own C code into Lisp source code.  The
  4163. idea is very simple:  The specified C code is inserted in the intermediate
  4164. C code that is generated by the KCL compiler.  In the following example,
  4165. \(fp)Clines\(fr) and \(fp)defentry\(fr) are top-level macros specific
  4166. to KCL.  The \(fp)Clines\(fr) macro form specifies the C code to be embedded,
  4167. in terms of strings, and the \(fp)defentry\(fr) form defines an entry
  4168. of the specified C function from KCL.
  4169. \(reserve 11)\(fp)
  4170.     (Clines
  4171.     "   int tak(x, y, z)                       "
  4172.     "   int x, y, z;                           "
  4173.     "   {   if (y >= x) return(z);             "
  4174.     "       else return(tak(tak(x-1, y, z),    "
  4175.     "                       tak(y-1, z, x),    "
  4176.     "                       tak(z-1, x, y)));  "
  4177.     "   }                                      "
  4178.     )
  4179.  
  4180.     (defentry tak (int int int) (int "tak"))
  4181. \(fr)
  4182.  
  4183.  
  4184. \(reserve 5)\(fg)
  4185. Port to VAX took three days.
  4186. \(fr)
  4187. Although KCL is made to be highly portable, certain minor changes had to
  4188. be done, when it was ported to VAX Unix 4.2 bsd.  These changes include:
  4189.  
  4190.     1. \(sm)The compiler top-level was slightly changed, because of
  4191. the differences of the calling sequence of the C compiler and of the handling
  4192. of object files.\(rm)
  4193.  
  4194.     2. \(sm)File system interface was changed to fit Unix 4.2 bsd.\(rm)
  4195.  
  4196.     3. \(sm)The following system parameters were redefined because
  4197. Vax's representation of floating point numbers differs from that of Eclipse.
  4198. \(fp)
  4199.         most-positive-short-float
  4200.         most-negative-short-float
  4201.         least-positive-short-float
  4202.         least-negative-short-float
  4203.         most-positive-long-float
  4204.         most-positive-double-float
  4205.         most-positive-single-float
  4206.         most-negative-long-float
  4207.         most-negative-double-float
  4208.         most-negative-single-float
  4209.         least-positive-long-float
  4210.         least-positive-double-float
  4211.         least-positive-single-float
  4212.         least-negative-long-float
  4213.         least-negative-double-float
  4214.         least-negative-single-float
  4215.         short-float-epsilon
  4216.         short-float-negative-epsilon
  4217.         long-float-epsilon
  4218.         double-float-epsilon
  4219.         single-float-epsilon
  4220.         long-float-negative-epsilon
  4221.         double-float-negative-epsilon
  4222.         single-float-negative-epsilon
  4223. \(fr)\(rm)
  4224.     4. \(sm)For the same reason as above, the following machine-dependent
  4225. Common Lisp functions were rewritten.
  4226. \(fp)
  4227.         decode-float
  4228.         scale-float
  4229.         float-radix
  4230.         float-digits
  4231.         float-precision
  4232.         integer-decode-float
  4233. \(fr)\(rm)
  4234.     5. The three assembler routines were rewritten.
  4235.  
  4236.     6. \(sm)The in-core loader that loads Fasl-file into the KCL memory was
  4237. changed.  This was a simple job because we used the standard linkage
  4238. editor \(fp)ld\(fr) of Unix.\(rm)
  4239.  
  4240.     7. \(sm)The memory dump routine was rewritten.\(rm)
  4241.  
  4242. The whole job of poring KCL to VAX Unix 4.2 bsd took three days.  Later,
  4243. we spent some more days,
  4244. to fix bugs in the ported version of KCL.
  4245.  
  4246.  
  4247. \(reserve 5)\(fg)
  4248. Port to SUN took three evenings.
  4249. \(fr)
  4250. Port to SUN Workstation was much easier than port to VAX, mainly because the
  4251. operating system is the same for both VAX and SUN.
  4252.  
  4253.     1. The compiler top-level of KCL/VAX was used without changes.
  4254.  
  4255.     2. The file system of KCL/VAX was used without changes.
  4256.  
  4257.     3. \(sm)The system parameters that depend on the representation of
  4258. floating point numbers were rewritten.\(rm)
  4259.  
  4260.     4. \(sm)The Common Lisp functions that depend on the representation of
  4261. floating point numbers were redefined.\(rm)
  4262.  
  4263.     5. The three assembler routines were rewritten.
  4264.  
  4265.     6. The in-core loader of KCL/VAX was used without changes.
  4266.  
  4267.     7. The memory dump routines of KCL/VAX was used without changes.
  4268.  
  4269. The whole job of poring KCL to SUN took three evenings.  Most of
  4270. the time was spent for the three assembler routines, because we did not know
  4271. anything about the MC68000 assembler at first.
  4272.  
  4273.  
  4274. \(reserve 5)\(fg)
  4275. Port to Ustation took one week.
  4276. \(fr)
  4277. Port to Ustation was relatively a hard job.  It took almost a week.  
  4278. The major difficulity was that
  4279. the C compiler of Unix V on Ustation recognized identifiers only by
  4280. the first seven characters.  As already mentioned, we used the convention that
  4281. the C function that implements the Common Lisp
  4282. function \(fi)function-name\(fr) is given
  4283. the name \(fp)L\(fi)function-name\(fr).  Thus, for example, the Common Lisp functions on packages such as
  4284. \(fp)
  4285.         package-name
  4286.         package-nickname
  4287.         package-shadowing-symbols
  4288.         package-use-list
  4289.         package-used-by-list
  4290.         packagep
  4291. \(fr)
  4292. are implemented by the C functions whose names all begin
  4293. with \(fp)Lpackage\(fr).  These C functions are regarded
  4294. to have the same name by the
  4295. C compiler.  This problem was solved by preparing a preprocessor program which
  4296. maps long identifiers into smaller ones.  This program is now used by the KCL
  4297. compiler on Ustation before the C compiler is called.
  4298.  
  4299.  
  4300. \(reserve 5)\(fg)
  4301. KCL is relatively compact.
  4302. \(fr)
  4303. The size of the object module of the whole KCL system (including the Compiler)
  4304. is:
  4305. \(reserve 4)
  4306.         KCL/AOS        1.78 Mbytes
  4307.         KCL/VAX    1.45 Mbytes
  4308.         KCL/SUN        1.56 Mbytes
  4309.         KCL/UST        1.56 Mbytes
  4310.  
  4311. Since all system initialization (such as loading the database of the KCL
  4312. compiler) has been done when the object module is created, the object module
  4313. size roughly corresponds to the initial size of the KCL process when
  4314. a KCL session is started, minus the initial size of the hole
  4315. in the heap (about 200 Kbytes).
  4316.  
  4317.  
  4318. \(reserve 5)\(fg)
  4319. Gabriel's benchmark.
  4320. \(fr)
  4321. The following table shows the results of Richard Gabriel's Lisp benchmark
  4322. tests with the four versions of KCL.  The results with
  4323. five other Common Lisp systems are also listed for comparison.  Each
  4324. number represents the CPU time (in second) for
  4325. compiled program.  '\(fp)*\(fr)' indicates that the time
  4326. includes garbage-collection time.  The data of S-1 Lisp and Spice Lisp are
  4327. found in:
  4328. \(reserve 6)
  4329. \(fi)
  4330. \(ce)Performance and Evaluation of Lisp Systems
  4331. \(ce)by
  4332. \(fr)\(ce)Richard P. Gabriel
  4333. \(ce)Computer Systems Ser. Research Reports,
  4334. \(ce)MIT Press, 1985
  4335.  
  4336. We received the data of Symbolics, DEC Common Lisp, and DG Common Lisp
  4337. directly from Dr. Richard Gabriel in April 1985.  We measured the
  4338. data for KCL in July 1985.  For the details of the benchmark
  4339. tests, refer to the paper above.
  4340.  
  4341.  
  4342. \(reserve 30)\(fp)
  4343.  \(fp)Benchmark |   Boyer  |  Browse  | Destruct | Traverse | Traverse \(fs)|
  4344.  \(fp)  Test    |          |          |          |Initialize|    Run   \(fs)|
  4345.  \(fs)-------------------------------------------------------------------\(fp)
  4346.  \(fp)          |          |          |          |          |          \(fs)|
  4347.  \(fp) Kyoto CL |   11.02  |   18.09  |    3.15  |    5.75  |   44.16  \(fs)|
  4348.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4349.  \(fp)          |          |          |          |          |          \(fs)|
  4350.  \(fp) Kyoto CL |   43.73  |   68.15* |    8.00  |   14.42  |  151.20  \(fs)|
  4351.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4352.  \(fp)          |          |          |          |          |          \(fs)|
  4353.  \(fp) Kyoto CL |   43.60* |   73.08* |   10.23  |   20.38  |  118.60  \(fs)|
  4354.  \(fp)   E15    |          |          |          |          |          \(fs)|
  4355.  \(fp)          |          |          |          |          |          \(fs)|
  4356.  \(fp) Kyoto CL |   47.00  |   81.37  |   14.10  |   26.30  |  160.58  \(fs)|
  4357.  \(fp)   SUN    |          |          |          |          |          \(fs)|
  4358.  \(fp)          |          |          |          |          |          \(fs)|
  4359.  \(fp)Symbolics |   11.99  |   30.8   |    3.03  |    8.62  |   49.95  \(fs)|
  4360.  \(fp)   3600   |          |          |          |          |          \(fs)|
  4361.  \(fp)          |          |          |          |          |          \(fs)|
  4362.  \(fp)  S-1 CL  |   10.03  |   10.2   |    0.91  |    1.93  |   30.1   \(fs)|
  4363.  \(fp) Mark IIA |          |          |          |          |          \(fs)|
  4364.  \(fp)          |          |          |          |          |          \(fs)|
  4365.  \(fp)  Spice   |  134.79  |  359.63  |   17.78  |   41.75  |  490.6   \(fs)|
  4366.  \(fp)   Perq   |          |          |          |          |          \(fs)|
  4367.  \(fp)          |          |          |          |          |          \(fs)|
  4368.  \(fp)  DEC CL  |   46.79  |  118.51  |    6.38  |   20.76  |  161.68  \(fs)|
  4369.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4370.  \(fp)          |          |          |          |          |          \(fs)|
  4371.  \(fp)   DG CL  |   29.3   |   59.91  |    6.95  |   27.77  |   45.86  \(fs)|
  4372.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4373.  \(fp)
  4374.  
  4375.  
  4376.  \(fp)Benchmark |    Tak   |   Stak   |   Ctak   |   Takl   |   Takr   \(fs)|
  4377.  \(fp)  Test    |          |          |          |          |          \(fs)|
  4378.  \(fs)-------------------------------------------------------------------\(fp)
  4379.  \(fp)          |          |          |          |          |          \(fs)|
  4380.  \(fp) Kyoto CL |    0.42  |    1.90  |    4.35  |    5.13  |    0.54  \(fs)|
  4381.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4382.  \(fp)          |          |          |          |          |          \(fs)|
  4383.  \(fp) Kyoto CL |    1.45  |    6.03  |   14.02  |   19.97  |    1.75  \(fs)|
  4384.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4385.  \(fp)          |          |          |          |          |          \(fs)|
  4386.  \(fp) Kyoto CL |    1.17  |    7.63  |    9.58  |   16.10  |    1.38  \(fs)|
  4387.  \(fp)   E15    |          |          |          |          |          \(fs)|
  4388.  \(fp)          |          |          |          |          |          \(fs)|
  4389.  \(fp) Kyoto CL |    1.48  |   11.02  |   16.88  |   23.35  |    1.67  \(fs)|
  4390.  \(fp)   SUN    |          |          |          |          |          \(fs)|
  4391.  \(fp)          |          |          |          |          |          \(fs)|
  4392.  \(fp)Symbolics |    0.6   |    2.58  |    7.65  |    6.44  |    0.6   \(fs)|
  4393.  \(fp)   3600   |          |          |          |          |          \(fs)|
  4394.  \(fp)          |          |          |          |          |          \(fs)|
  4395.  \(fp)  S-1 CL  |    0.29  |    4.31  |    0.82  |    2.92  |    0.58  \(fs)|
  4396.  \(fp) Mark IIA |          |          |          |          |          \(fs)|
  4397.  \(fp)          |          |          |          |          |          \(fs)|
  4398.  \(fp)  Spice   |    4.7   |   13.5   |    8.4   |   24.0   |    7.7   \(fs)|
  4399.  \(fp)   Perq   |          |          |          |          |          \(fs)|
  4400.  \(fp)          |          |          |          |          |          \(fs)|
  4401.  \(fp)  DEC CL  |    1.83  |    4.11  |    8.09  |    7.34  |    3.42  \(fs)|
  4402.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4403.  \(fp)          |          |          |          |          |          \(fs)|
  4404.  \(fp)   DG CL  |    0.89  |    3.09  |    1.79  |    5.52  |    1.21  \(fs)|
  4405.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4406.  \(fp)
  4407.  
  4408.  
  4409.  \(fp)Benchmark |   Deriv  |  DDeriv  |   Div2   |   Div2   |    FFT   \(fs)|
  4410.  \(fp)  Test    |          |          | Iterative| Recursive|          \(fs)|
  4411.  \(fs)-------------------------------------------------------------------\(fp)
  4412.  \(fp)          |          |          |          |          |          \(fs)|
  4413.  \(fp) Kyoto CL |    4.85  |    5.93  |    1.99  |    2.73  |    1.55  \(fs)|
  4414.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4415.  \(fp)          |          |          |          |          |          \(fs)|
  4416.  \(fp) Kyoto CL |   18.98  |   23.07  |    7.48  |   11.25  |    9.07  \(fs)|
  4417.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4418.  \(fp)          |          |          |          |          |          \(fs)|
  4419.  \(fp) Kyoto CL |   22.07* |   25.38* |    9.95* |   12.60* |   74.62  \(fs)|
  4420.  \(fp)   E15    |          |          |          |          |          \(fs)|
  4421.  \(fp)          |          |          |          |          |          \(fs)|
  4422.  \(fp) Kyoto CL |   20.72  |   24.77  |    9.32  |   12.30  |   94.07  \(fs)|
  4423.  \(fp)   SUN    |          |          |          |          |          \(fs)|
  4424.  \(fp)          |          |          |          |          |          \(fs)|
  4425.  \(fp)Symbolics |    5.12  |    5.24  |    1.85  |    2.89  |    4.75  \(fs)|
  4426.  \(fp)   3600   |          |          |          |          |          \(fs)|
  4427.  \(fp)          |          |          |          |          |          \(fs)|
  4428.  \(fp)  S-1 CL  |    4.99  |    3.27  |    0.82  |    1.49  |    1.44  \(fs)|
  4429.  \(fp) Mark IIA |          |          |          |          |          \(fs)|
  4430.  \(fp)          |          |          |          |          |          \(fs)|
  4431.  \(fp)  Spice   |   71.8   |   77.7   |   28.15  |   40.69  |   59.0   \(fs)|
  4432.  \(fp)   Perq   |          |          |          |          |          \(fs)|
  4433.  \(fp)          |          |          |          |          |          \(fs)|
  4434.  \(fp)  DEC CL  |   13.76  |   ---    |    5.0   |    9.84  |   32.69  \(fs)|
  4435.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4436.  \(fp)          |          |          |          |          |          \(fs)|
  4437.  \(fp)   DG CL  |    5.6   |    8.11  |    2.86  |    4.48  |   62.78  \(fs)|
  4438.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4439.  \(fp)
  4440.  
  4441.  
  4442.  \(fp)Benchmark |   Puzzle |  Triang  |  Fprint  |   Fread  |  Tprint  \(fs)|
  4443.  \(fp)  Test    |          |          |          |          |          \(fs)|
  4444.  \(fs)-------------------------------------------------------------------\(fp)
  4445.  \(fp)          |          |          |          |          |          \(fs)|
  4446.  \(fp) Kyoto CL |    6.76  |  104.85  |    1.98  |    2.45  |    1.74  \(fs)|
  4447.  \(fp)  MV10000 |          |          |          |          |          \(fs)|
  4448.  \(fp)          |          |          |          |          |          \(fs)|
  4449.  \(fp) Kyoto CL |   20.57  |  366.12  |    5.73  |    5.77  |    6.55  \(fs)|
  4450.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4451.  \(fp)          |          |          |          |          |          \(fs)|
  4452.  \(fp) Kyoto CL |   41.30  |  341.23* |    9.83  |    6.07  |   11.58  \(fs)|
  4453.  \(fp)   E15    |          |          |          |          |          \(fs)|
  4454.  \(fp)          |          |          |          |          |          \(fs)|
  4455.  \(fp) Kyoto CL |   49.13  |  499.68  |   10.05  |    7.62  |    8.50  \(fs)|
  4456.  \(fp)   SUN    |          |          |          |          |          \(fs)|
  4457.  \(fp)          |          |          |          |          |          \(fs)|
  4458.  \(fp)Symbolics |   13.89  |  151.7   |    2.6   |    4.6   |    4.9   \(fs)|
  4459.  \(fp)   3600   |          |          |          |          |          \(fs)|
  4460.  \(fp)          |          |          |          |          |          \(fs)|
  4461.  \(fp)  S-1 CL  |    1.82  |   62.06  |   ---    |   ---    |   ---    \(fs)|
  4462.  \(fp) Mark IIA |          |          |          |          |          \(fs)|
  4463.  \(fp)          |          |          |          |          |          \(fs)|
  4464.  \(fp)  Spice   |   75.14  | 1488.85  |   20.0   |   26.0   |   22.6   \(fs)|
  4465.  \(fp)   Perq   |          |          |          |          |          \(fs)|
  4466.  \(fp)          |          |          |          |          |          \(fs)|
  4467.  \(fp)  DEC CL  |   47.48  |  360.85  |    3.94  |    7.24  |    2.85  \(fs)|
  4468.  \(fp)  VAX 780 |          |          |          |          |          \(fs)|
  4469.  \(fp)          |          |          |          |          |          \(fs)|
  4470.  \(fp)   DG CL  |  138.2   |  151.2   |    2.35  |    4.65  |    2.83  \(fs)|
  4471.  \(fp)  MV10000 |          |          |          |          |          |
  4472. \(fr)
  4473.  
  4474.  
  4475. \(fg) 
  4476.  
  4477. \(ce)Appendix C. Kyoto Common Lisp Installation Guide
  4478. \(set-page pp-installation)
  4479. \(fr)
  4480. This appendix explains how to install the KCL system, separately for
  4481. each version of KCL.
  4482.  
  4483.  
  4484. \(reserve 5)\(fg)
  4485. C.1. Installation of KCL/AOS\(set-page pp-install-aos)
  4486. \(fr)
  4487. \(reserve 3)
  4488. 1. Prepare a directory (hereafter called \(fi)KCL directory\(fr)) for Kyoto Common
  4489. Lisp.  In the following examples, we suppose that the KCL directory is
  4490. \(fp):UDD:KCL\(fr).
  4491.  
  4492. \(reserve 3)
  4493. 2. Load the distribution tape to the KCL directory.
  4494. \(reserve 3)\(fp)
  4495.     ) DIR
  4496.     :UDD:KCL
  4497.     ) LOAD
  4498. \(fr)
  4499. You will find that the subdirectory \(fp)PORT\(fr) has been created.  The \(fp)PORT\(fr) subdirectory contains everything that is needed to run KCL.  Files in this directory are:
  4500. \(reserve 2)
  4501.     Documents:
  4502.     \(fp)README\(fr)            this file
  4503. \(reserve 5)
  4504.     Executable files:
  4505.     \(fp)KCL.PR\(fr)            the KCL interpreter and compiler
  4506.     \(fp)KCL.ST\(fr)
  4507.     \(fp)BUILD_FASL.PR\(fr)        the fasl-file builder
  4508.     \(fp)FECL2.PR\(fr)        the FeCl2 editor
  4509. \(reserve 5)
  4510.     Command files:
  4511.     \(fp)KCL.CLI\(fr)            to invoke KCL
  4512.     \(fp)LC.CLI\(fr)            to invoke the KCL compiler
  4513.     \(fp)LC1.CLI\(fr)            to invoke the KCL compiler
  4514.     \(fp)FECL2.CLI\(fr)        to invoke the FeCl2 editor
  4515. \(reserve 2)
  4516.      Header file:
  4517.     \(fp)CMPINCLUDE.H\(fr)        the header file for the KCL compiler
  4518. \(reserve 2)
  4519.      Miscellaneous:
  4520.     \(fp)FECL2.CMD\(fr)        FeCl2 editor command table
  4521.  
  4522. \(reserve 3)
  4523. 3. Customize the command files.
  4524.  
  4525. The command file \(fp)KCL.CLI\(fr) consists of the following command lines
  4526. to invoke the KCL interpreter.
  4527. \(reserve 4)\(fp)
  4528.     push;prom pop
  4529.     sea :usr:dgc [!sea]
  4530.     x :udd:[!user]:port:%0-% :udd:[!user]:port:
  4531.     pop
  4532. \(fr)
  4533. Replace the two occurrences of "\(fp)[!user]\(fr)" with the name of the KCL directory
  4534. (i.e., \(fp)KCL\(fr) in our example).
  4535. \(reserve 4)\(fp)
  4536.     push;prom pop
  4537.     sea :usr:dgc [!sea]
  4538.     x :udd:KCL:port:%0-% :udd:KCL:port:
  4539.     pop
  4540. \(fr)
  4541. And move this file to an appropriate command directory, say \(fp):UTIL,\(fr) so
  4542. that all KCL users can access it.
  4543.  
  4544. If the name of the directory that includes DG's C compiler is not
  4545. \(fp):USR:DGC\(fr), you should replace it with the appropriate directory name,
  4546. so that the KCL compiler can access the C compiler by \(fp)CC.PR\(fr).
  4547.  
  4548. You can use the commands \(fp)LC.CLI\(fr) and \(fp)LC1.CLI\(fr) to invoke the compiler directly
  4549. from the CLI.  The content of \(fp)LC.CLI\(fr) is:
  4550. \(reserve 7)\(fp)
  4551.     push
  4552.      prompt pop level
  4553.      sea :usr:dgc [!sea]
  4554.      WRITE Compiling %1%.LSP.
  4555.       proc/def/ioc/block/pri=3 &
  4556.       :udd:[!user]:port:kcl :udd:[!user]:port: %1% %1% U10000
  4557.     pop
  4558. \(fr)
  4559. Customize these command files in the same way as for the \(fp)KCL.CLI\(fr) command file
  4560. above.
  4561.  
  4562. \(reserve 3)
  4563. 4. Install the header file
  4564.  
  4565. Copy the header file \(fp)CMPINCLUDE.H\(fr) to the standard directory for C include
  4566. files, say \(fp):USR:DGC\(fr).
  4567.  
  4568. \(reserve 5)\(fg)
  4569. C.2. Installation of KCL/VAX\(set-page pp-install-vax)
  4570. \(fr)
  4571. \(reserve 3)
  4572. 1. Prepare a directory (hereafter called \(fi)KCL directory\(fr)) for Kyoto Common
  4573. Lisp.  In the following examples, we suppose that the KCL directory is
  4574. \(fp)/usr/kcl\(fr).
  4575.  
  4576. \(reserve 3)
  4577. 2. Load the distribution tape to the KCL directory.
  4578. \(reserve 3)\(fp)
  4579.     % pwd
  4580.     /usr/kcl
  4581.     % tar x
  4582. \(fr)
  4583. You will find that the subdirectory \(fp)unixport\(fr) has been created.  The \(fp)unixport\(fr) subdirectory contains everything that is needed to run KCL and
  4584. the KCL compiler.  Files in this directory are:
  4585. \(reserve 2)
  4586.     Documents:
  4587.     \(fp)readme\(fr)            this file
  4588. \(reserve 2)
  4589.     Executable files:
  4590.     \(fp)saved_kcl\(fr)        the KCL interpreter and compiler
  4591. \(reserve 4)
  4592.     Command files:
  4593.     \(fp)kcl\(fr)            to invoke KCL
  4594.     \(fp)lc\(fr)            to invoke the KCL compiler
  4595.     \(fp)lc1\(fr)            to invoke the KCL compiler
  4596. \(reserve 2)
  4597.      Header file:
  4598.     \(fp)cmpinclude.h\(fr)        the header file for the KCL compiler
  4599.  
  4600. \(reserve 3)
  4601. 3. Customize the command files.
  4602.  
  4603. The command file \(fp)kcl\(fr) consists of a single line command to invoke the KCL
  4604. interpreter.
  4605. \(reserve 2)\(fp)
  4606.     #
  4607.     ~/unixport/saved_kcl ~/unixport/
  4608. \(fr)
  4609. Replace two '\(fp)~\(fr)'s with the pathname of the KCL directory (i.e., \(fp)/usr/kcl\(fr) in our example).
  4610. \(reserve 2)\(fp)
  4611.     #
  4612.     /usr/kcl/unixport/saved_kcl /usr/kcl/unixport/
  4613. \(fr)
  4614. And move this file to an appropriate command directory, say \(fp)/usr/bin\(fr), so
  4615. that all KCL users can access it.
  4616.  
  4617. You can use the commands \(fp)lc\(fr) and \(fp)lc1\(fr) to invoke the compiler directly from the
  4618. shell.  The content of \(fp)lc\(fr) is:
  4619. \(reserve 3)\(fp)
  4620.     #
  4621.     echo Compiling $1.lsp
  4622.     ~/unixport/saved_kcl ~/unixport/ $1 $1 U1000
  4623. \(fr)
  4624. Customize these command files in the same way as for the kcl command file
  4625. above.
  4626.  
  4627. \(reserve 3)
  4628. 4. Install the header file
  4629.  
  4630. Copy the header file \(fp)cmpinclude.h\(fr) to the standard directory for C include
  4631. files, say \(fp)/usr/include\(fr).
  4632.  
  4633.  
  4634. \(reserve 5)\(fg)
  4635. C.3. Installation of KCL/SUN\(set-page pp-install-sun)
  4636. \(fr)
  4637. \(reserve 3)
  4638. 1. Prepare a directory (hereafter called \(fi)KCL directory\(fr)) for Kyoto Common
  4639. Lisp.  In the following examples, we suppose that the KCL directory is
  4640. \(fp)/usr/kcl\(fr).
  4641.  
  4642. \(reserve 3)
  4643. 2. Load the distribution tape to the KCL directory.
  4644. \(reserve 3)\(fp)
  4645.     % pwd
  4646.     /usr/kcl
  4647.     % tar x
  4648. \(fr)
  4649. You will find that the subdirectory \(fp)unixport\(fr) has been created.  The \(fp)unixport\(fr) subdirectory contains everything that is needed to run KCL and
  4650. the KCL compiler.  Files in this directory are:
  4651. \(reserve 2)
  4652.     Documents:
  4653.     \(fp)readme\(fr)            this file
  4654. \(reserve 2)
  4655.     Executable files:
  4656.     \(fp)saved_kcl\(fr)        the KCL interpreter and compiler
  4657. \(reserve 4)
  4658.     Command files:
  4659.     \(fp)kcl\(fr)            to invoke KCL
  4660.     \(fp)lc\(fr)            to invoke the KCL compiler
  4661.     \(fp)lc1\(fr)            to invoke the KCL compiler
  4662. \(reserve 2)
  4663.      Header file:
  4664.     \(fp)cmpinclude.h\(fr)        the header file for the KCL compiler
  4665.  
  4666. \(reserve 3)
  4667. 3. Customize the command files.
  4668.  
  4669. The command file \(fp)kcl\(fr) consists of a single line command to invoke the KCL
  4670. interpreter.
  4671. \(reserve 2)\(fp)
  4672.     #
  4673.     ~/unixport/saved_kcl ~/unixport/
  4674. \(fr)
  4675. Replace two '\(fp)~\(fr)'s with the pathname of the KCL directory (i.e., \(fp)/usr/kcl\(fr) in
  4676. our example).
  4677. \(reserve 2)\(fp)
  4678.     #
  4679.     /usr/kcl/unixport/saved_kcl /usr/kcl/unixport/
  4680. \(fr)
  4681. And move this file to an appropriate command directory, say \(fp)/usr/bin\(fr), so
  4682. that all KCL users can access it.
  4683.  
  4684. You can use the commands lc and lc1 to invoke the compiler directly from the
  4685. shell.  The content of lc is:
  4686. \(reserve 3)\(fp)
  4687.     #
  4688.     echo Compiling $1.lsp
  4689.     ~/unixport/saved_kcl ~/unixport/ $1 $1 U1000
  4690. \(fr)
  4691. Customize these command files in the same way as for the kcl command file
  4692. above.
  4693.  
  4694. \(reserve 3)
  4695. 4. Install the header file
  4696.  
  4697. Copy the header file \(fp)cmpinclude.h\(fr) to the standard directory for C include
  4698. files, say \(fp)/usr/include\(fr).
  4699.  
  4700.  
  4701. \(reserve 5)\(fg)
  4702. C.4. Installation of KCL/UST\(set-page pp-install-ust)
  4703. \(fr)
  4704. \(reserve 3)
  4705. 1. Prepare a directory (hereafter called \(fi)KCL directory\(fr)) for Kyoto Common
  4706. Lisp.  In the following examples, we suppose that the KCL directory is
  4707. \(fp)/usr/kcl\(fr).
  4708.  
  4709. \(reserve 3)
  4710. 2. Three floppy disks are used for the distribution.  Load the floppy disks
  4711. to the KCL directory by the multi-volume option of the tar command.  (Insert
  4712. the first disk to the drive and issue the tar command.  Then, you will be
  4713. prompted to change the disks.)
  4714. \(reserve 3)\(fp)
  4715.     % pwd
  4716.     /usr/kcl
  4717.     % tar xvfBM /dev/rdy0g 1976
  4718. \(fr)
  4719. You will find that the subdirectory \(fp)unixport\(fr) has been created.  The \(fp)unixport\(fr) subdirectory contains everything that is needed to run KCL and
  4720. the KCL compiler.  Files in this directory are:
  4721. \(reserve 2)
  4722.     Documents:
  4723.     \(fp)readme\(fr)            this file
  4724. \(reserve 4)
  4725.     Executable files:
  4726.     \(fp)saved_kcl\(fr)        the KCL interpreter and compiler
  4727.     \(fp)ild\(fr)            incremental loader
  4728.     \(fp)trans\(fr)            translator from Unix 4.2 to Unix V
  4729. \(reserve 4)
  4730.     Command Source files:
  4731.     \(fp)kcl.c\(fr)            to invoke KCL
  4732.     \(fp)lc.c\(fr)            to invoke the KCL compiler
  4733.     \(fp)lc1.c\(fr)            to invoke the KCL compiler
  4734. \(reserve 2)
  4735.      Header file:
  4736.     \(fp)cmpinclude.h\(fr)        the header file for the KCL compiler
  4737.  
  4738. \(reserve 3)
  4739. 3. Customize the command files.
  4740.  
  4741. The source file \(fp)kcl.c\(fr) consists of a C-language program to invoke the KCL
  4742. interpreter.  Replace all \(fp)/usr/ukcl\(fr) in this file with the pathname of the KCL directory
  4743. (i.e., \(fp)/usr/kcl\(fr) in our example), and compile this file.
  4744. \(fp)
  4745.     % cc -o kcl kcl.c
  4746. \(fr)
  4747. And move the object file to an appropriate command directory, say \(fp)/usr/bin\(fr),
  4748. so that all KCL users can access it.
  4749.  
  4750. You can use the source files \(fp)lc.c\(fr) and \(fp)lc1.c\(fr) to invoke the compiler directly
  4751. from the shell.  Customize these source files in the same way as for the kcl command file above.
  4752.  
  4753. \(reserve 3)
  4754. 4. Install the header file
  4755.  
  4756. Copy the header file \(fp)cmpinclude.h\(fr) to the standard directory for C include
  4757. files, say \(fp)/usr/include\(fr).
  4758.  
  4759. \(setq *page-number* (1- pp-contents))
  4760.  
  4761. \(fg) 
  4762.  
  4763. \(ce)Table of Contents
  4764.  
  4765. \(fr)\(bd)
  4766.  Preface\(ra)\(do-string (format nil "~3d" pp-preface))
  4767.  Acknowledgements\(ra)\(do-string (format nil "~3d" pp-acknowledgements))
  4768.  Table of Contents\(ra)\(do-string (format nil "~3d" pp-contents))
  4769.  
  4770.  Chapter 1. How to Start and End a KCL Session\(ra)\(do-string (format nil "~3d" pp-1))
  4771.  
  4772.  Chapter 2. Data Types\(ra)\(do-string (format nil "~3d" pp-2))
  4773.         2.1. Numbers\(ra)\(do-string (format nil "~3d" pp-2-1))
  4774.       2.1.1. Integers\(ra)\(do-string (format nil "~3d" pp-2-1-1))
  4775.       2.1.2. Ratios\(ra)\(do-string (format nil "~3d" pp-2-1-2))
  4776.       2.1.3. Floating-point Numbers\(ra)\(do-string (format nil "~3d" pp-2-1-3))
  4777.       2.1.4. Complex Numbers\(ra)\(do-string (format nil "~3d" pp-2-1-4))
  4778.     2.2. Characters\(ra)\(do-string (format nil "~3d" pp-2-2))
  4779.       2.2.1. Standard Characters\(ra)\(do-string (format nil "~3d" pp-2-2-1))
  4780.       2.2.2. Line Divisions\(ra)\(do-string (format nil "~3d" pp-2-2-2))
  4781.       2.2.3. Non-standard Characters\(ra)\(do-string (format nil "~3d" pp-2-2-3))
  4782.       2.2.4. Character Attributes\(ra)\(do-string (format nil "~3d" pp-2-2-4))
  4783.       2.2.5. String Characters\(ra)\(do-string (format nil "~3d" pp-2-2-5))
  4784.     2.3. Symbols\(ra)\(do-string (format nil "~3d" pp-2-3))
  4785.     2.4. Lists and Conses\(ra)\(do-string (format nil "~3d" pp-2-4))
  4786.     2.5. Arrays\(ra)\(do-string (format nil "~3d" pp-2-5))
  4787.       2.5.1. Vectors\(ra)\(do-string (format nil "~3d" pp-2-5-1))
  4788.       2.5.2. Strings\(ra)\(do-string (format nil "~3d" pp-2-5-2))
  4789.       2.5.3. Bit-Vectors\(ra)\(do-string (format nil "~3d" pp-2-5-3))
  4790.     2.6. Hash Tables\(ra)\(do-string (format nil "~3d" pp-2-6))
  4791.     2.7. Readtables\(ra)\(do-string (format nil "~3d" pp-2-7))
  4792.     2.8. Packages\(ra)\(do-string (format nil "~3d" pp-2-8))
  4793.     2.9. Pathnames\(ra)\(do-string (format nil "~3d" pp-2-9))
  4794.     2.10. Streams\(ra)\(do-string (format nil "~3d" pp-2-10))
  4795.     2.11. Random-States\(ra)\(do-string (format nil "~3d" pp-2-11))
  4796.     2.12. Structures\(ra)\(do-string (format nil "~3d" pp-2-12))
  4797.     2.13. Functions\(ra)\(do-string (format nil "~3d" pp-2-13))
  4798.     2.14. Unreadable Data Objects\(ra)\(do-string (format nil "~3d" pp-2-14))
  4799.     2.15. Overlap, Inclusion, and Disjointness of Types\(ra)\(do-string (format nil "~3d" pp-2-15))
  4800.  
  4801.  Chapter 3. Input and Output\(ra)\(do-string (format nil "~3d" pp-3))
  4802.     3.1. Read Macros\(ra)\(do-string (format nil "~3d" pp-3-1))
  4803.     3.2. Input and Output Functions\(ra)\(do-string (format nil "~3d" pp-3-2))
  4804.  
  4805.  Chapter 4. Memory Management\(ra)\(do-string (format nil "~3d" pp-4))
  4806.     4.1. Implementation Types\(ra)\(do-string (format nil "~3d" pp-4-1))
  4807.     4.2. Heap and Relocatable Areas\(ra)\(do-string (format nil "~3d" pp-4-2))
  4808.     4.3. The Garbage Collector\(ra)\(do-string (format nil "~3d" pp-4-3))
  4809.     4.4. Allocation Functions\(ra)\(do-string (format nil "~3d" pp-4-4))
  4810.     4.5. Storage Information\(ra)\(do-string (format nil "~3d" pp-4-5))
  4811.  
  4812.  Chapter 5. Debugging Facilities\(ra)\(do-string (format nil "~3d" pp-5))
  4813.     5.1. The Tracer\(ra)\(do-string (format nil "~3d" pp-5-1))
  4814.     5.2. The Stepper\(ra)\(do-string (format nil "~3d" pp-5-2))
  4815.     5.3. Errors\(ra)\(do-string (format nil "~3d" pp-5-3))
  4816.     5.4. The Break Loop\(ra)\(do-string (format nil "~3d" pp-5-4))
  4817.     5.5. Describe and Inspect\(ra)\(do-string (format nil "~3d" pp-5-5))
  4818.  
  4819.  Chapter 6. The Compiler\(ra)\(do-string (format nil "~3d" pp-6))
  4820.  
  4821.  Chapter 7. Declarations\(ra)\(do-string (format nil "~3d" pp-7))
  4822.     7.1. Declaration Specifiers\(ra)\(do-string (format nil "~3d" pp-7-1))
  4823.     7.2. Significant Type Specifiers\(ra)\(do-string (format nil "~3d" pp-7-2))
  4824.     7.3. Treatment of Type Declarations\(ra)\(do-string (format nil "~3d" pp-7-3))
  4825.       7.3.1. Variable Allocations\(ra)\(do-string (format nil "~3d" pp-7-3-1))
  4826.       7.3.2. Built-in Functions that Operate on Raw Data Directly\(ra)\(do-string (format nil "~3d" pp-7-3-2))
  4827.       7.3.3. Arguments/Values Passing\(ra)\(do-string (format nil "~3d" pp-7-3-3))
  4828.  
  4829.  Chapter 8. Operating System Interface\(ra)\(do-string (format nil "~3d" pp-8))
  4830.  
  4831.  Chapter 9. Macros\(ra)\(do-string (format nil "~3d" pp-9))
  4832.     9.1. System Macros\(ra)\(do-string (format nil "~3d" pp-9-1))
  4833.     9.2. Defmacro Lambda-Lists\(ra)\(do-string (format nil "~3d" pp-9-2))
  4834.  
  4835.  Chapter 10. The C Language Interface\(ra)\(do-string (format nil "~3d" pp-10))
  4836.  
  4837.  Chapter 11. The Editor\(ra)\(do-string (format nil "~3d" pp-11))
  4838.  
  4839.  Appendix A. KCL Summary\(ra)\(do-string (format nil "~3d" pp-summary))
  4840.  
  4841.  Appendix B. An Overview of Kyoto Common Lisp\(ra)\(do-string (format nil "~3d" pp-overview))
  4842.  
  4843.  Appendix C. Kyoto Common Lisp Installation Guide\(ra)\(do-string (format nil "~3d" pp-installation))
  4844.     C.1. Installation of KCL/AOS\(ra)\(do-string (format nil "~3d" pp-install-aos))
  4845.     C.2. Installation of KCL/VAX\(ra)\(do-string (format nil "~3d" pp-install-vax))
  4846.     C.3. Installation of KCL/SUN\(ra)\(do-string (format nil "~3d" pp-install-sun))
  4847.     C.4. Installation of KCL/UST\(ra)\(do-string (format nil "~3d" pp-install-ust))
  4848.